RTS: Trail

This commit is contained in:
Krzosa Karol
2023-04-19 15:01:43 +02:00
parent b7385221ac
commit 2d5c2d89bc
2 changed files with 46 additions and 26 deletions

View File

@@ -77,9 +77,7 @@ Add(&guys, {100, 100})
#load "array.core"
#load "map.core"
V2I :: struct
x: int
y: int
V2I :: struct ;; x: int; y: int
WinX := 1280
WinY := 720
@@ -108,6 +106,21 @@ main :: (): int
InitWindow(WinX, WinY, "Testing")
SetTargetFPS(60)
orange := ORANGE
orange.a = 255/2
brown := BROWN
brown.a = 255/2
actor_color := GREEN
actor_color.a = 255/2
past_actor_color := BLUE
past_actor_color.a = 255/2
target_color := RED
target_color.a = 255/2
for !WindowShouldClose()
WinX = GetScreenWidth()
WinY = GetScreenHeight()
@@ -117,12 +130,6 @@ main :: (): int
Dt = GetFrameTime()
map := &MAP_CurrentMap
orange := ORANGE
orange.a = 255/2
brown := BROWN
brown.a = 255/2
if IsKeyPressed(KEY_F1) ;; Mode = 0
if IsKeyPressed(KEY_F2) ;; Mode = 1
@@ -203,11 +210,20 @@ main :: (): int
for i := 0, i < map.actors.len, i += 1
actor_it := map.actors.data + i
r := Rectangle{actor_it.p.x->F32 * RectX, actor_it.p.y->F32 * RectY, RectX, RectY}
// 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)
main_p := Vector2{actor_it.p.x->F32 * RectX + RectX/2, actor_it.p.y->F32 * RectY + RectY/2}
DrawCircleV(main_p, RectX/3, actor_color)
// DrawRectangleRec(r, actor_color)
DrawRectangleRec(target_r, target_color)
smaller_the_further: F32 = 0
for tile_i := actor_it.tiles_visited.len - 1, tile_i >= 0, tile_i -= 1
tile_it := actor_it.tiles_visited.data + tile_i
p := Vector2{tile_it.x->F32 * RectX + RectX/2, tile_it.y->F32 * RectY + RectY/2}
DrawCircleV(p, RectX/3 - smaller_the_further, past_actor_color)
smaller_the_further += 0.3
for path_i := 0, path_i < actor_it.open_paths.len, path_i += 1
path_it := actor_it.open_paths.data + path_i
@@ -237,22 +253,23 @@ main :: (): int
DrawCircleV(p0, 4, LIGHTGRAY)
DrawCircleV(p1, 4, LIGHTGRAY)
menu_open := false
if menu_open
text_size := 24
text_p := 4
text_y := WinY - text_size
text_size := 24
text_p := 4
text_y := WinY - text_size
DrawText("Space :: PathFind", text_p, text_y, text_size, GRAY)
text_y -= text_size
DrawText("F4 :: Randomize actors", text_p, text_y, text_size, GRAY)
text_y -= text_size
DrawText("Space :: PathFind", text_p, text_y, text_size, GRAY)
text_y -= text_size
DrawText("F4 :: Randomize actors", text_p, text_y, text_size, GRAY)
text_y -= text_size
DrawText("F3 :: Simulate actors", text_p, text_y, text_size, GRAY)
text_y -= text_size
text: *char = "F1 :: Block placing"
if Mode == 1 ;; text = "F2 :: Actor placing"
DrawText(text, text_p, text_y, text_size, GRAY)
text_y -= text_size
DrawText("F3 :: Simulate actors", text_p, text_y, text_size, GRAY)
text_y -= text_size
text: *char = "Mode(F1) :: Block placing"
if Mode == 1 ;; text = "Mode(F2) :: Actor placing"
DrawText(text, text_p, text_y, text_size, GRAY)
text_y -= text_size