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} } render_controls :: proc(world: ^World) { if world.phase != .Build do return bar_y := bottom_bar_y() rl.DrawRectangle(0, bar_y, SCREEN_W, CONTROL_BAR_H, CONTROL_BAR_BG) arch := get_archetype(.Archer) archer, start_wave_btn := build_controls_layout() 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 rl.DrawRectangleRec(archer, arch_bg) label := fmt.ctprintf("Archer - %dg", arch.cost) rl.DrawText(label, i32(archer.x) + 6, i32(archer.y) + 4, 14, OVERLAY_TEXT_COLOR) wave_bg := CONTROL_BUTTON_COLOR if rl.CheckCollisionPointRec(mouse, start_wave_btn) do wave_bg = CONTROLS_SHOP_HOVER rl.DrawRectangleRec(start_wave_btn, wave_bg) rl.DrawText( "Start Wave", i32(start_wave_btn.x) + 8, i32(start_wave_btn.y) + 3, 16, OVERLAY_TEXT_COLOR, ) }