RTS: Bug fixing, improvements

This commit is contained in:
Krzosa Karol
2023-04-20 15:52:07 +02:00
parent 6be3b60cd4
commit 7c69537283
2 changed files with 4 additions and 11 deletions

View File

@@ -168,14 +168,11 @@ main :: (): int
for i := 0, i < map.actors.len, i += 1 for i := 0, i < map.actors.len, i += 1
it := map.actors.data + i it := map.actors.data + i
MAP_MoveTowardsTarget(it) MAP_MoveTowardsTarget(it)
MAP_PathFindUpdate(map)
if IsKeyPressed(KEY_F4) if IsKeyPressed(KEY_F4)
MAP_RandomizeActors() MAP_RandomizeActors()
if IsKeyDown(KEY_SPACE)
for i := 0, i < map.actors.len, i += 1
it := map.actors.data + i
MAP_PathFindStep(it)
BeginDrawing() BeginDrawing()
ClearBackground(RAYWHITE) ClearBackground(RAYWHITE)
@@ -199,9 +196,6 @@ main :: (): int
Add(&ANI_SetTiles, {true, {x,y}}) Add(&ANI_SetTiles, {true, {x,y}})
if colliding && IsMouseButtonDown(MOUSE_BUTTON_RIGHT) if colliding && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)
Add(&ANI_SetTiles, {false, {x,y}}) 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} if colliding == true ;; color = Color{a = 100}
DrawRectangleRec(r2, color) DrawRectangleRec(r2, color)
@@ -301,8 +295,6 @@ main :: (): int
DrawRectangleRec(MouseSelectionBox, COLOR_SelectionBox) DrawRectangleRec(MouseSelectionBox, COLOR_SelectionBox)
MAP_PathFindUpdate(map)
menu_open := false menu_open := false
if menu_open if menu_open
text_size := 24 text_size := 24

View File

@@ -75,7 +75,7 @@ MAP_SetTargetP :: (s: *MAP_Actor, p: V2I)
Reset(&s.close_paths) Reset(&s.close_paths)
MAP_GetRandomP :: (m: *MAP_Map): V2I 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 return result
MAP_GetRandomUnblockedP :: (m: *MAP_Map): V2I MAP_GetRandomUnblockedP :: (m: *MAP_Map): V2I
@@ -83,6 +83,7 @@ MAP_GetRandomUnblockedP :: (m: *MAP_Map): V2I
p := MAP_GetRandomP(m) p := MAP_GetRandomP(m)
if m.data[p.x + p.y * m.x] == 0 if m.data[p.x + p.y * m.x] == 0
return p return p
Assert(false, "Invalid codepath") Assert(false, "Invalid codepath")
r: V2I; return r r: V2I; return r
@@ -209,7 +210,7 @@ MAP_PathFindStep :: (s: *MAP_Actor, compute_history: bool = true): bool
return false return false
MAP_PathFind :: (s: *MAP_Actor) MAP_PathFind :: (s: *MAP_Actor)
for i := 0, i < 128, i += 1 for i := 0, i < 32, i += 1
done := MAP_PathFindStep(s, false) done := MAP_PathFindStep(s, false)
if done ;; break if done ;; break
MAP_RecomputeHistory(s) MAP_RecomputeHistory(s)