Files
odin-iso-test/src2/ui.odin
T
2026-08-03 21:11:00 +03:00

27 lines
823 B
Odin

package main
import hm "core:container/handle_map"
import rl "vendor:raylib"
ui_draw_world_hp_bar :: proc(b: ^BaseEntity, actor: ^Actor) {
hp_ratio := f32(actor.hp) / f32(actor.max_hp)
bar_w := b.col_size * 3
bar_pos := b.pos + rl.Vector2{-bar_w / 2, -b.col_size - 10}
rl.DrawRectangleV(bar_pos, {bar_w, 4}, {60, 60, 60, 255})
rl.DrawRectangleV(bar_pos, {bar_w * hp_ratio, 4}, {220, 40, 40, 255})
}
ui_draw :: proc(state: ^GameState) {
_, p := get_player(state)
hp: i32 = 0
max_hp: i32 = 1
if p != nil {
hp = p.hp
max_hp = p.max_hp
}
rl.DrawText(rl.TextFormat("HP: %d/%d", hp, max_hp), 12, 12, 20, rl.RAYWHITE)
rl.DrawText(rl.TextFormat("Entities: %d", hm.len(state.entities)), 12, 36, 16, {180, 180, 180, 255})
rl.DrawText("[SPACE] attack [WASD] move", 12, SCREEN_H - 28, 14, {120, 120, 120, 255})
}