49 lines
1.3 KiB
Odin
49 lines
1.3 KiB
Odin
package game
|
|
|
|
import "core:fmt"
|
|
import rl "vendor:raylib"
|
|
|
|
render_overlay :: proc(world: ^World) {
|
|
rl.DrawRectangle(0, 0, SCREEN_W, OVERLAY_BAR_H, OVERLAY_BAR_COLOR)
|
|
|
|
font_size: i32 = 18
|
|
y: i32 = (OVERLAY_BAR_H - font_size) / 2
|
|
x: i32 = OVERLAY_PADDING
|
|
gap: i32 : 16
|
|
|
|
|
|
gold := fmt.ctprintf("Gold: %d", world.gold)
|
|
rl.DrawText(gold, OVERLAY_PADDING, OVERLAY_PADDING, 18, OVERLAY_GOLD_COLOR)
|
|
x += rl.MeasureText(gold, font_size) + gap
|
|
|
|
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}
|
|
}
|
|
|