package game import "core:fmt" import rl "vendor:raylib" bottom_bar_y :: proc() -> i32 { return SCREEN_H - CONTROL_BAR_H } build_controls_layout :: proc() -> (archer, start_wave_btn: rl.Rectangle) { bar_y := f32(bottom_bar_y()) arch_w: f32 = 120 wave_w: f32 = 110 gap: f32 = 12 x := f32((SCREEN_W - int(arch_w + gap + wave_w)) / 2) archer = {x, bar_y + 8, arch_w, 24} start_wave_btn = {x + arch_w + gap, bar_y + 8, wave_w, 24} return } poll_controls_command :: proc(world: ^World) -> Command { if world.phase != .Build do return Command{kind = .None} mouse := rl.GetMousePosition() if rl.IsMouseButtonPressed(.LEFT) { archer, start_wave := build_controls_layout() if rl.CheckCollisionPointRec(mouse, archer) { world.selected_tower = .Archer } if rl.CheckCollisionPointRec(mouse, start_wave) { return Command{kind = .Start_Wave} } } return Command{kind = .None} } draw_archer_button :: proc(world: ^World, archer: rl.Rectangle) { arch := get_archetype(.Archer) mouse := rl.GetMousePosition() arch_bg := CONTROLS_SHOP_IDLE if world.selected_tower == .Archer do arch_bg = CONTROL_SHOP_SELECTED if rl.CheckCollisionPointRec(mouse, archer) do arch_bg = CONTROL_BUTTON_HOVER label := fmt.ctprintf("Archer - %dg", arch.cost) draw_button(archer, label, arch_bg, 14, OVERLAY_TEXT_COLOR) } draw_start_wave_button :: proc(start_wave_rect: rl.Rectangle, mouse: rl.Vector2) { bg := CONTROL_BUTTON_COLOR if rl.CheckCollisionPointRec(mouse, start_wave_rect) do bg = CONTROL_BUTTON_HOVER draw_button(start_wave_rect, "Start Wave", bg, 16, OVERLAY_TEXT_COLOR) } render_controls :: proc(world: ^World) { if world.phase != .Build do return mouse := rl.GetMousePosition() bar_y := bottom_bar_y() rl.DrawRectangle(0, bar_y, SCREEN_W, CONTROL_BAR_H, CONTROL_BAR_BG) archer, start_wave_rect := build_controls_layout() draw_archer_button(world, archer) draw_start_wave_button(start_wave_rect, mouse) }