Add bitmap font, UI primitives and a HUD with message log

Ports the CP437 font renderer from wds to the framebuffer: proportional
advance from measured ink bounds, luminance-keyed mask, word wrap. The
right 80 px strip becomes a HUD with name, HP bar, population and a log
fed from sim events; Attacked/Died now carry the type ids the log needs,
since the victim is gone from the world by the time events are read.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 17:31:17 +02:00
co-authored by Claude Opus 5
parent 03a12c82dc
commit bb12f095d8
9 changed files with 415 additions and 104 deletions
+13 -6
View File
@@ -158,13 +158,20 @@ Sprite rendering, camera follow and entity interpolation have all landed.
---
### Later — UI / HUD
### UI / HUD *(first pass done)*
- Bitmap font renderer: 8×8 glyph sheet PNG, `draw_text(frame, font, x, y, color, text)` — see `notes/04`
- UI primitives in `game/src/ui.rs`: `fill_rect`, `draw_rect`, `draw_hbar` — see `notes/05`
- HUD layout (320×240): HP bar + player name bottom 16px, message log right panel
- A real clip-rect on the blit primitives belongs here — once the viewport and HUD panels are
two distinct regions, the abstraction earns its keep. Not before.
- [x] Bitmap font: `game/src/font.rs`, CP437 atlas (32×8 cells, codepoint = index),
proportional advance from measured ink bounds, luminance-keyed mask, `wrap`.
Ported from `wds`; the atlas is `assets/fonts/cga-8x8.png` (Oldschool PC Font
Pack CGA 8×8). See `notes/04-text_renderer.md`
- [x] UI primitives in `game/src/ui.rs`: `fill_rect`, `draw_rect`, `draw_hbar`
- [x] HUD in the 80 px strip right of the viewport (`Game::render_hud`): name, HP bar,
population, and a message log fed from the sim events (only fights involving the
player; newest at the bottom, wrapped to the panel)
- A real clip-rect on the blit primitives — the HUD currently relies on being drawn
*after* the viewport, which overwrites the right-edge bleed. Fine until a panel
overlaps the world.
- Player name is a constant; a character/stat screen comes with inventory.
---