The HUD and Inventory Builder
Last reviewed
IntermediateWhat you'll learn
~55 min- Build a Phaser HUD with health bar, blood rage meter, and ammo indicator
- Implement a 4x4 inventory grid with pickup items and keyboard toggle
- Create a pause screen with player stats and resume functionality
- Add a minimap placeholder that frames future level integration
What you’re building
Your combat loop works. Enemies take damage, the player dodges, particles fly. But right now the player has no idea how much health they have left, whether their rage meter is full, or what they picked up three rooms ago. The game feels like a tech demo because it is missing the layer that turns mechanics into readable gameplay: the HUD.
BloodRayne had one of the better HUDs of its era. Rayne’s health was literally blood — she healed by feeding on enemies, so the health bar pulsed and drained in a way that made you feel the vampire fantasy. She had a rage meter that filled during combat and unleashed a devastating mode when full. Dual blades and guns meant you needed weapon indicators. Your remake needs the same information density without the same screen clutter.
Forty minutes from now you will have a full HUD overlay with a blood-themed health bar, a rage meter, an ammo/weapon indicator, pickup items that populate a toggleable 4x4 inventory grid, a pause screen with stats, and a minimap placeholder ready for level data.
HUD elements bound to game state variables, rendered as a separate Phaser scene layered on top of gameplay. This pattern — a persistent UI layer that reads from shared state — is identical to dashboards, status bars, and notification systems in any application.
The showcase
Here is what the finished HUD system gives you:
- Blood health bar: Top-left, red-to-dark gradient that drains left-to-right. Pulses gently when below 30%. Fills back up when the player “feeds” (placeholder mechanic tied to a key press for now).
- Blood rage meter: Below the health bar, a red bar (dark red to crimson to orange-red) that fills as the player deals damage. When full, the border glows and the player can activate rage mode (R key) for a temporary damage boost.
- Weapon indicator: Bottom-left icon showing current weapon (blade or gun) with ammo count for guns. Switch weapons with Q.
- Pickup items: Collectible objects placed in the scene. Walking over them adds them to inventory with a brief flash notification.
- Inventory grid: Press I to toggle a 4x4 grid overlay. Items show as colored icons with names on hover. Click an item to “use” it (restores health, fills rage, etc.).
- Pause screen: Press ESC to pause. Dark overlay with player stats (health, rage, items collected, enemies defeated, time played). Press ESC again or click Resume to continue.
- Minimap placeholder: Top-right corner, a small bordered rectangle showing a static grid. This is a frame that will display actual room layouts once level data exists from the Level Editor Lite lesson.
Before you start
If your AI tool is open from the previous lesson, leave it (/exit, or Ctrl+D in Antigravity) so you are back at your terminal prompt. Create a folder for this lesson and step into it:
mkdir -p ~/retro-remake/15-hud-inventory-builder && cd ~/retro-remake/15-hud-inventory-builderIn Windows PowerShell, run mkdir ~/retro-remake/15-hud-inventory-builder; cd ~/retro-remake/15-hud-inventory-builder. In a desktop agent app, open ~/retro-remake/15-hud-inventory-builder as your workspace folder. Then start your AI tool the way Workbench Setup showed.
Switch to plan mode
Switch into Plan mode (Shift+Tab, /plan, or the mode picker) so your agent asks about the HUD layout, shared state, inventory slots, and pause screen before generating files.
The conversation
Each message below is an example. Say it in your own words.
Say what you want
Ask for a browser-based HUD, 4x4 inventory overlay, and pause screen layered over a test gameplay room:
Build a browser-based game HUD, a 4x4 inventory grid, and a pause screen layered over a playable test room with pickups and enemies. Ask me what you need first.Answer its questions
Your agent will ask about the HUD elements, gameplay controls and pickups, inventory behavior, and pause screen stats:
| If it asks | You might say |
|---|---|
| Which HUD elements should stay fixed on screen? | Blood health bar, rage meter, blade/gun ammo indicator, top-right minimap placeholder, and pickup notifications. |
| How should the test gameplay room work? | WASD movement, Space to attack, Q to swap weapon, F to feed, R for rage, and 5 pickups. |
| What are the 5 pickup items and how does the inventory work? | Press I for a 4x4 grid holding health potions, rage crystals, ammo boxes, shield shards, and key fragments. |
| What should the pause screen show on ESC? | Freeze gameplay and show health, rage, weapon, items collected, enemies defeated, time played, and a Resume button. |
| How should the HUD, inventory, and pause screen stay in sync? | Keep one shared game state so gameplay, the HUD bars, the inventory slots, and the pause stats update together. |
Read the plan
Before approving the build, check the agent’s plan for these four details:
- Decoupled parallel scenes (Phaser 3 with Vite):
GameScenelaunchesHUDScenein parallel oncreate(), whileInventoryScene(toggled withI, disabled while paused) andPauseScene(toggled withESC, pausingGameScenephysics) run as overlays with fixed cameras (scrollat0, 0). - Single shared state (
src/state.js): storeshealth(100),rage(0-100,rageActive),currentWeapon(bladeorgun),ammo(30),inventory(up to 16 items),enemiesDefeated,itemsCollected,timeStarted, andpaused. - Blood health and rage feedback: the top-left
BLOODbar pulses when health drops below 30% and refills by 20 when feeding (Fnear an enemy); theRAGEbar fills by 5 per hit (10 on feed), glows at 100, and drains over 5 seconds of 2x damage when activated withR. - Usable 4x4 inventory and minimap frame: clicking a red potion (+25 HP), purple crystal (+30 rage), or ammo box (+15 ammo) in the 4x4 grid applies its effect and removes the item, while the top-right 104x104
MAPframe renders a static 5x5 grid with a center player dot ready for level data later.
If the plan puts HUD drawing inside GameScene instead of a parallel overlay with its own camera, steer it before approving:
Keep the HUD, inventory, and pause screen as separate overlay layers reading from shared state so the HUD stays fixed in place even when the game camera scrolls.Once the plan covers all four checks, approve it and let your agent build the project. After testing pickups, feeding, inventory use, and pausing in the browser, ask your agent to save a Git checkpoint.
HUD work is much cleaner when your plan spells out screen corners (BLOOD and RAGE top-left, weapon bottom-left, MAP top-right, notifications top-center) and non-conflicting keys (WASD, Space, Q, F, R, I, ESC) up front.
What you get
After the AI finishes generating, the project folder structure looks like this:
15-hud-inventory-builder/ package.json index.html src/ main.js GameScene.js HUDScene.js InventoryScene.js PauseScene.js state.jsFire it up
Ask your agent to install what is needed, start the local server, and open the game:
Install the packages, start the local server, and open the HUD and inventory prototype in my browser.Or run it from a terminal:
cd ~/retro-remake/15-hud-inventory-buildernpm installnpm run devOpen the URL (usually http://localhost:5173). You should see the gameplay scene with a purple player square, red enemies, and colored pickup circles. The HUD is already live in the top-left corner — health bar, rage meter, weapon indicator, and minimap placeholder.
Walk into an enemy to see health drain. Hit SPACE to attack and watch rage build. Press F near an enemy to feed and restore health. Collect pickups by walking over them. Press I to open inventory. Press ESC to pause.
If something is off
| Problem | Follow-up prompt |
|---|---|
| HUD elements move with the game camera | The health bar, rage meter, and minimap scroll away when the player moves instead of staying pinned to the corners of the screen. Lock the HUD overlay to fixed screen coordinates so it never scrolls with the room. |
| Inventory grid items are invisible | I pick up items in the room, but when I press I the 4x4 inventory grid looks empty. Refresh the grid slots whenever I open the inventory so every collected item shows its colored icon and hover name. |
| Pause does not stop gameplay | When I press ESC, the pause overlay appears, but enemies keep moving and hitting me in the background. Freeze all movement and combat while the pause screen is open, and resume cleanly when I unpause. |
| Rage mode does not activate | Pressing R when the rage bar is full does nothing. Make pressing R at full rage trigger a 5-second rage mode that doubles attack damage, glows around the player, and steadily drains the rage bar to zero. |
Deep dive
The architecture here is the most important thing to understand, because it applies far beyond games.
Separate scenes for UI layers. Phaser lets you run multiple scenes simultaneously. The GameScene handles gameplay logic and physics. The HUDScene runs on top, reading from shared state every frame, but with its own camera that never scrolls. This is the same pattern as a dashboard overlay on any application — the data source and the display layer are decoupled.
Shared state as the single source of truth. The state.js module exports one object. GameScene writes to it (health changes, items collected). HUDScene reads from it (bar widths, numbers). InventoryScene reads and writes (using items removes them). PauseScene reads (stats display). Nobody passes data directly between scenes. This is a simple version of state management that scales cleanly.
Why a 4x4 grid? Sixteen slots is enough to be interesting without requiring scroll or pagination logic. It matches classic action game inventories — Resident Evil 4 used a grid, Diablo used a grid, BloodRayne’s inventory was simpler but the concept is the same. If you need more slots later, change one number in the grid renderer.
The minimap is intentionally a placeholder. It draws a static grid with a green dot. That is all it needs to be right now. In Level Editor Lite you will build a level editor that exports room layouts as JSON. When that data exists, the minimap will render actual room shapes. Building the frame now means the integration later is a single request, not a redesign.
🔍BloodRayne's blood health mechanicclick to expand
In the original BloodRayne (2002), Rayne’s primary healing mechanic was feeding on enemies. She would grab a Nazi soldier, bite their neck, and drain their blood to restore her health. This created a risk-reward loop: you had to get close to enemies to heal, which meant exposing yourself to damage. The blood rage meter built during combat and unleashed a devastating aura attack. Your HUD captures both mechanics — the pulsing health bar at low health creates urgency (“I need to feed”), and the rage meter filling during combat creates anticipation (“almost ready for rage mode”). These are not just UI elements. They are feedback loops that drive player behavior.
Customize it
Add a combo counter
Add a top-center HUD combo counter that increments on hits within 2 seconds, turns yellow at 5+ and shaking orange at 10+, and grants 2 bonus rage per combo level above 5.Add an equipment slot system
Add Head, Body, and Accessory equipment slots below the 4x4 inventory grid so equipment items can be equipped for passive stat bonuses (+10 max health, +20 max rage, -1 damage taken).Try it yourself
- Walk through the plan-mode conversation above and let your agent build the project.
- Ask your agent to start the app (or run
npm install && npm run dev) and test every interaction: take damage, feed, collect items, open inventory, use a potion, activate rage, pause and check stats. - Intentionally let your health drop below 30% and watch the health bar pulse. That visual feedback is what makes the vampire fantasy feel real.
- Open inventory and use items. Verify they disappear from the grid and the effect applies.
- Check the minimap placeholder. It is just a frame right now — and that is correct. The level editor you build in Level Editor Lite will fill it.
Key takeaways
- UI layers as separate scenes keep HUD logic cleanly separated from gameplay logic. No tangled update functions.
- Shared state is the bridge between scenes. One object, multiple readers, clean data flow.
- Blood-themed health is not just aesthetic — the pulsing bar at low health creates urgency that drives the core feed mechanic.
- Placeholders are architecture. The minimap frame exists now so the level editor integration later is trivial.
- Keyboard shortcuts (I, ESC, Q, R, F) must be deliberate and non-conflicting. Document them in the pause screen so the player always has a reference.
A HUD that reads well is the difference between a prototype that feels like a game and a prototype that feels like a tech demo. Rayne’s blood health bar told a story — “I’m a vampire, I need to feed.” Your HUD should do the same. Every element is a sentence in the conversation between your game and the player.
What’s next
Your player can see their health, manage their inventory, and pause the game. But the game world is still silent — there is no story, no objectives, no sense of progress. In the next lesson you will build a dialogue and objective system that gives the player mission briefings, NPC interactions, branching choices, and a save/load system. That is the layer that turns a combat sandbox into something with narrative direction.