Files
tower-defense-prototype/game/render.odin
T
2026-06-13 23:33:03 -07:00

67 lines
1.7 KiB
Odin

package game
import "core:fmt"
import rl "vendor:raylib"
render_world :: proc(world: ^World) {
for y in 0 ..< MAP_H {
for x in 0 ..< MAP_W {
c := tile_color(world.world_map.tiles[y][x])
rl.DrawRectangle(i32(x * TILE_SIZE), i32(y * TILE_SIZE), TILE_SIZE, TILE_SIZE, c)
}
}
for t in world.towers {
rl.DrawRectangle(
i32(t.position.x - 14),
i32(t.position.y - 14),
28,
28,
rl.Color{255, 203, 0, 255},
)
}
for i in 0 ..< MAX_PROJECTILES {
p := world.projectiles[i]
if !p.active do continue
rl.DrawCircle(i32(p.position.x), i32(p.position.y), 4, rl.GOLD)
}
for i in 0 ..< MAX_ENEMIES {
e := world.enemies[i]
if !e.active do continue
rl.DrawCircle(i32(e.position.x), i32(e.position.y), 11, rl.MAROON)
rl.DrawText(
fmt.ctprintf("%d", e.health),
i32(e.position.x) - 4,
i32(e.position.y) - 18,
12,
rl.WHITE,
)
}
for i in 0 ..< MAX_PROJECTILES {
p := world.projectiles[i]
if !p.active do continue
rl.DrawCircle(i32(p.position.x), i32(p.position.y), 4, rl.GOLD)
}
rl.DrawText(fmt.ctprintf("Gold: %d", world.gold), 10, 10, 22, rl.BLACK) // Gold HUD
rl.DrawText(fmt.ctprintf("Base HP: %d", world.base_health), 10, 32, 22, rl.BLACK) // HP HUD
rl.DrawText(fmt.ctprintf("Enemies: %d", active_enemy_count(world)), 10, 54, 22, rl.BLACK)
rl.DrawText(fmt.ctprintf("Wave: %d / %d", world.wave, MAX_WAVES), 10, 76, 22, rl.BLACK)
switch world.phase {
case .Build:
rl.DrawText("Build - click towers, N = start wave", 10, 98, 22, rl.BLACK)
case .Combat:
rl.DrawText("Combat!", 10, 98, 22, rl.MAROON)
case .Game_Over:
rl.DrawText("GAME_OVER", 260, 280, 40, rl.RED)
case .Victory:
rl.DrawText("Victory!", 260, 280, 40, rl.GREEN)
}
}