50 lines
1.3 KiB
Odin
50 lines
1.3 KiB
Odin
package game
|
|
|
|
import clay "../clay-odin"
|
|
import "core:fmt"
|
|
import rl "vendor:raylib"
|
|
|
|
UI_BAR_COLOR :: clay.Color{20, 40, 20, 200}
|
|
UI_TEXT_COLOR :: clay.Color{240, 240, 230, 255}
|
|
UI_GOLD_COLOR :: clay.Color{255, 215, 80, 255}
|
|
|
|
build_hud :: proc(world: ^World) {
|
|
if clay.UI(clay.ID("HudBar"))({
|
|
layout = {
|
|
layoutDirection = .LeftToRight,
|
|
sizing = {
|
|
width = clay.SizingGrow({}),
|
|
height = clay.SizingFixed(28),
|
|
},
|
|
padding = clay.PaddingAll(6),
|
|
childGap = 8,
|
|
childAlignment = {y = .Center},
|
|
},
|
|
backgroundColor = UI_BAR_COLOR,
|
|
}) {
|
|
gold_text := fmt.tprintf("Gold: %d", world.gold)
|
|
clay.Text(gold_text, clay.TextElementConfig{
|
|
textColor = UI_GOLD_COLOR,
|
|
fontId = UI_FONT_ID,
|
|
fontSize = 18,
|
|
})
|
|
}
|
|
}
|
|
|
|
render_hud :: proc(world: ^World) {
|
|
rl.DrawText(fmt.ctprintf("Base HP: %d", world.base_health), 10, 32, 22, rl.BLACK)
|
|
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)
|
|
}
|
|
}
|