set up clay ui + move gold rendering to clay
This commit is contained in:
+29
-2
@@ -1,11 +1,38 @@
|
||||
package game
|
||||
|
||||
import clay "../clay-odin"
|
||||
import "core:fmt"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
UI_BAR_COLOR :: clay.Color{20, 40, 20, 200}
|
||||
UI_TEXT_COLOR :: clay.Color{240, 240, 230, 255}
|
||||
UI_GOLD_COLOR :: clay.Color{255, 215, 80, 255}
|
||||
|
||||
ui_text_scratch: [64]u8
|
||||
|
||||
build_hud :: proc(world: ^World) {
|
||||
if clay.UI(clay.ID("HudBar"))(
|
||||
{
|
||||
layout = {
|
||||
layoutDirection = .LeftToRight,
|
||||
sizing = {width = clay.SizingGrow({}), height = clay.SizingFixed(28)},
|
||||
padding = clay.PaddingAll(6),
|
||||
childGap = 8,
|
||||
childAlignment = {y = .Center},
|
||||
},
|
||||
backgroundColor = UI_BAR_COLOR,
|
||||
},
|
||||
) {
|
||||
gold_text := fmt.bprintf(ui_text_scratch[:], "Gold: %d", world.gold)
|
||||
clay.Text(
|
||||
gold_text,
|
||||
clay.TextElementConfig{textColor = UI_GOLD_COLOR, fontId = UI_FONT_ID, fontSize = 18},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
render_hud :: proc(world: ^World) {
|
||||
rl.DrawText(fmt.ctprintf("Gold: %d", world.gold), 10, 10, 22, rl.BLACK) // Gold HUD
|
||||
rl.DrawText(fmt.ctprintf("Base HP: %d", world.base_health), 10, 32, 22, rl.BLACK) // HP HUD
|
||||
rl.DrawText(fmt.ctprintf("Base HP: %d", world.base_health), 10, 32, 22, rl.BLACK)
|
||||
rl.DrawText(fmt.ctprintf("Enemies: %d", active_enemy_count(world)), 10, 54, 22, rl.BLACK)
|
||||
rl.DrawText(fmt.ctprintf("Wave: %d / %d", world.wave, MAX_WAVES), 10, 76, 22, rl.BLACK)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user