Core RTS: Path finding seems to work!

This commit is contained in:
Krzosa Karol
2023-04-18 17:26:08 +02:00
parent bea10a621e
commit 56eb7e6de2
4 changed files with 89 additions and 13 deletions

View File

@@ -98,6 +98,9 @@ main :: (): int
InitWindow(WinX, WinY, "Testing")
SetTargetFPS(60)
MAP_PathFindStart(MAP_CurrentMap.actors.data)
MAP_PathFindStep()
for !WindowShouldClose()
WinX = GetScreenWidth()
WinY = GetScreenHeight()
@@ -107,6 +110,8 @@ main :: (): int
if IsKeyPressed(KEY_F1) ;; Mode := 0
if IsKeyPressed(KEY_F2) ;; Mode := 1
if IsKeyDown(KEY_SPACE)
MAP_PathFindStep()
BeginDrawing()
ClearBackground(RAYWHITE)
@@ -122,7 +127,6 @@ main :: (): int
colliding := CheckCollisionPointRec(MouseP, r)
if Mode == 0 && colliding && IsMouseButtonDown(MOUSE_BUTTON_LEFT) ;; *it = 1
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = V2I{x,y}
color := GREEN
if *it == 1 ;; color = RED
@@ -138,9 +142,18 @@ main :: (): int
DrawRectangleRec(r, YELLOW)
DrawRectangleRec(target_r, PURPLE)
for i := 0, i < MAP_OpenPaths.len, i += 1
it := MAP_OpenPaths.data + i
r := Rectangle{it.p.x->F32 * RectX, it.p.y->F32 * RectY, RectX, RectY}
DrawRectangleRec(r, ORANGE)
if MAP_ReachedTarget
for i := 0, i < MAP_History.len, i += 1
it := MAP_History.data + i
r := Rectangle{it.p.x->F32 * RectX, it.p.y->F32 * RectY, RectX, RectY}
DrawRectangleRec(r, BLACK)
DrawText("Reached target !", 0, 0, 32, BLACK)
// DrawFPS(0, 0)
// DrawText(TextFormat("Testing %d", 32), 100, 100, 20, MAROON)
EndDrawing()
return 0