Core RTS: Actor movement
This commit is contained in:
@@ -101,27 +101,29 @@ main :: (): int
|
||||
InitWindow(WinX, WinY, "Testing")
|
||||
SetTargetFPS(60)
|
||||
|
||||
MAP_PathFindStart(MAP_CurrentMap.actors.data)
|
||||
MAP_PathFindStep()
|
||||
|
||||
for !WindowShouldClose()
|
||||
WinX = GetScreenWidth()
|
||||
WinY = GetScreenHeight()
|
||||
MouseX = GetMouseX()
|
||||
MouseY = GetMouseY()
|
||||
MouseP = GetMousePosition()
|
||||
map := &MAP_CurrentMap
|
||||
|
||||
|
||||
if IsKeyPressed(KEY_F1) ;; Mode = 0
|
||||
if IsKeyPressed(KEY_F2) ;; Mode = 1
|
||||
if IsKeyPressed(KEY_F3)
|
||||
MAP_Reset()
|
||||
for i := 0, i < map.actors.len, i += 1
|
||||
it := map.actors.data + i
|
||||
MAP_MoveTowardsTarget(it)
|
||||
if IsKeyDown(KEY_SPACE)
|
||||
MAP_PathFindStep()
|
||||
for i := 0, i < map.actors.len, i += 1
|
||||
it := map.actors.data + i
|
||||
MAP_PathFindStep(it)
|
||||
|
||||
BeginDrawing()
|
||||
ClearBackground(RAYWHITE)
|
||||
|
||||
map := &MAP_CurrentMap
|
||||
for x := 0, x < map.x, x += 1
|
||||
for y := 0, y < map.y, y += 1
|
||||
it := map.data + (x + y*map.x)
|
||||
@@ -141,23 +143,24 @@ main :: (): int
|
||||
DrawRectangleRec(r2, color)
|
||||
|
||||
for i := 0, i < map.actors.len, i += 1
|
||||
it := map.actors.data + i
|
||||
r := Rectangle{it.p.x->F32 * RectX, it.p.y->F32 * RectY, RectX, RectY}
|
||||
target_r := Rectangle{it.target_p.x->F32 * RectX, it.target_p.y->F32 * RectY, RectX, RectY}
|
||||
actor_it := map.actors.data + i
|
||||
r := Rectangle{actor_it.p.x->F32 * RectX, actor_it.p.y->F32 * RectY, RectX, RectY}
|
||||
target_r := Rectangle{actor_it.target_p.x->F32 * RectX, actor_it.target_p.y->F32 * RectY, RectX, RectY}
|
||||
|
||||
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)
|
||||
for path_i := 0, path_i < actor_it.open_paths.len, path_i += 1
|
||||
path_it := actor_it.open_paths.data + path_i
|
||||
path_r := Rectangle{path_it.p.x->F32 * RectX, path_it.p.y->F32 * RectY, RectX, RectY}
|
||||
DrawRectangleRec(path_r, ORANGE)
|
||||
|
||||
if actor_it.state == MAP_PATH_REACHED
|
||||
for path_i := 0, path_i < actor_it.history.len, path_i += 1
|
||||
path_it := actor_it.history.data + path_i
|
||||
path_r := Rectangle{path_it.p.x->F32 * RectX, path_it.p.y->F32 * RectY, RectX, RectY}
|
||||
DrawRectangleRec(path_r, BLACK)
|
||||
|
||||
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)
|
||||
|
||||
if Mode == 0 ;; DrawText("F1", 0, 0, 32, BLACK)
|
||||
if Mode == 1 ;; DrawText("F2", 0, 0, 32, BLACK)
|
||||
|
||||
Reference in New Issue
Block a user