diff --git a/build/rtsgame/main.core b/build/rtsgame/main.core index a866188..257c086 100644 --- a/build/rtsgame/main.core +++ b/build/rtsgame/main.core @@ -168,14 +168,11 @@ main :: (): int for i := 0, i < map.actors.len, i += 1 it := map.actors.data + i MAP_MoveTowardsTarget(it) + MAP_PathFindUpdate(map) if IsKeyPressed(KEY_F4) MAP_RandomizeActors() - if IsKeyDown(KEY_SPACE) - for i := 0, i < map.actors.len, i += 1 - it := map.actors.data + i - MAP_PathFindStep(it) BeginDrawing() ClearBackground(RAYWHITE) @@ -199,9 +196,6 @@ main :: (): int Add(&ANI_SetTiles, {true, {x,y}}) if colliding && IsMouseButtonDown(MOUSE_BUTTON_RIGHT) Add(&ANI_SetTiles, {false, {x,y}}) - // if Mode == 1 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) ;; MAP_ActorSetP(MAP_CurrentMap.actors.data, {x,y}) - // if Mode == 1 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; MAP_CurrentMap.actors.data[0].target_p = V2I{x,y} - if colliding == true ;; color = Color{a = 100} DrawRectangleRec(r2, color) @@ -301,8 +295,6 @@ main :: (): int DrawRectangleRec(MouseSelectionBox, COLOR_SelectionBox) - MAP_PathFindUpdate(map) - menu_open := false if menu_open text_size := 24 diff --git a/build/rtsgame/map.core b/build/rtsgame/map.core index 601e351..6279727 100644 --- a/build/rtsgame/map.core +++ b/build/rtsgame/map.core @@ -75,7 +75,7 @@ MAP_SetTargetP :: (s: *MAP_Actor, p: V2I) Reset(&s.close_paths) MAP_GetRandomP :: (m: *MAP_Map): V2I - result := V2I{GetRandomValue(0, MAP_CurrentMap.x), GetRandomValue(0, MAP_CurrentMap.y)} + result := V2I{GetRandomValue(0, MAP_CurrentMap.x - 1), GetRandomValue(0, MAP_CurrentMap.y - 1)} return result MAP_GetRandomUnblockedP :: (m: *MAP_Map): V2I @@ -83,6 +83,7 @@ MAP_GetRandomUnblockedP :: (m: *MAP_Map): V2I p := MAP_GetRandomP(m) if m.data[p.x + p.y * m.x] == 0 return p + Assert(false, "Invalid codepath") r: V2I; return r @@ -209,7 +210,7 @@ MAP_PathFindStep :: (s: *MAP_Actor, compute_history: bool = true): bool return false MAP_PathFind :: (s: *MAP_Actor) - for i := 0, i < 128, i += 1 + for i := 0, i < 32, i += 1 done := MAP_PathFindStep(s, false) if done ;; break MAP_RecomputeHistory(s)