From 54b10f000bb4e7dc02338203cdf6028dbcdaea35 Mon Sep 17 00:00:00 2001 From: codegirl-007 Date: Thu, 18 Jun 2026 01:31:06 -0700 Subject: [PATCH] add a start wave button --- game/commands.odin | 3 +++ game/constants.odin | 3 +++ game/hud.odin | 1 - game/overlay.odin | 26 ++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/game/commands.odin b/game/commands.odin index 9869ce3..fb021e2 100644 --- a/game/commands.odin +++ b/game/commands.odin @@ -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} } diff --git a/game/constants.odin b/game/constants.odin index 74c7294..a433b69 100644 --- a/game/constants.odin +++ b/game/constants.odin @@ -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} + diff --git a/game/hud.odin b/game/hud.odin index 7476307..523d04b 100644 --- a/game/hud.odin +++ b/game/hud.odin @@ -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: diff --git a/game/overlay.odin b/game/overlay.odin index 20cc9a9..dcce60f 100644 --- a/game/overlay.odin +++ b/game/overlay.odin @@ -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} }