add a start wave button
This commit is contained in:
@@ -15,6 +15,9 @@ Command :: struct {
|
||||
}
|
||||
|
||||
gather_commands :: proc(world: ^World) -> Command {
|
||||
ui_cmd := overlay_ui_command(world)
|
||||
if ui_cmd.kind != .None do return ui_cmd
|
||||
|
||||
if world.phase == .Build && rl.IsKeyPressed(.N) {
|
||||
return Command{kind = .Start_Wave}
|
||||
}
|
||||
|
||||
@@ -26,3 +26,6 @@ OVERLAY_BAR_COLOR :: rl.Color{20, 24, 20, 200}
|
||||
OVERLAY_GOLD_COLOR :: rl.Color{255, 215, 80, 255}
|
||||
OVERLAY_TEXT_COLOR :: rl.Color{240, 240, 230, 255}
|
||||
|
||||
OVERLAY_BUTTON_COLOR :: rl.Color{60, 120, 60, 255}
|
||||
OVERLAY_BUTTON_HOVER :: rl.Color{80, 150, 80, 255}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ render_hud :: proc(world: ^World) {
|
||||
|
||||
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:
|
||||
|
||||
@@ -18,5 +18,31 @@ render_overlay :: proc(world: ^World) {
|
||||
|
||||
hp := fmt.ctprintf("Health: %d", world.base_health)
|
||||
rl.DrawText(hp, x, y, font_size, OVERLAY_TEXT_COLOR)
|
||||
|
||||
if world.phase == .Build {
|
||||
btn := start_wave_button_rect()
|
||||
mouse := rl.GetMousePosition()
|
||||
hovered := rl.CheckCollisionPointRec(mouse, btn)
|
||||
bg := hovered ? OVERLAY_BUTTON_HOVER : OVERLAY_BUTTON_COLOR
|
||||
rl.DrawRectangleRec(btn, bg)
|
||||
rl.DrawText("Start Wave", i32(btn.x) + 8, i32(btn.y) + 3, 16, OVERLAY_TEXT_COLOR)
|
||||
}
|
||||
}
|
||||
|
||||
start_wave_button_rect :: proc() -> rl.Rectangle {
|
||||
return {x = f32(SCREEN_W - 120), y = 3, width = 110, height = 22}
|
||||
}
|
||||
|
||||
overlay_ui_command :: proc(world: ^World) -> Command {
|
||||
if world.phase != .Build do return Command{kind = .None}
|
||||
|
||||
mouse := rl.GetMousePosition()
|
||||
btn := start_wave_button_rect()
|
||||
|
||||
if rl.CheckCollisionPointRec(mouse, btn) && rl.IsMouseButtonPressed(.LEFT) {
|
||||
return Command{kind = .Start_Wave}
|
||||
}
|
||||
|
||||
return Command{kind = .None}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user