Voxel Game Maker

Docs Tutorials

A HUD of your own

Design your own on-screen display: a health bar, an item counter, a warning, a pause menu and an inventory screen.

In the editor: Welcome ▸ Tutorials ▸ 3.4 ▸ ▶ Start goes on in your My Playground project with this lesson's checklist.

Build · about 35 minutes · Advanced mode

What you'll make: your own health bar and coin counter, a warning that shows only when health is low, a pause menu, and an inventory screen.

Before you start: do Your first Quick code. Use a project with Coin pickups (as in A coin hunt) and something that can hurt the player (as in Enemies and health). Stay in Advanced.

#1. A new HUD

  1. Open the HUD tab (F10).
  2. Click + HUD ▾ ▸ Empty.
  3. With nothing picked, the right side is the HUD card. Tick Shown when the game starts.

#2. A health bar and a counter

  1. On the left, on the Add page, double-click Health bar in the Library list. Drag it where you want it.
  2. Double-click Item counter and pick Coin when it asks which item to count.
  3. Open the Built-in & art page (next to Add and Layers) and untick the built-in Health bar, so there's only one.

Play it now: get hurt and watch your bar drop. Pick up a coin and the counter goes up.

#3. A low-health warning

  1. Under Basics, double-click + Text. Double-click the new text on the screen and type Find a heart!. Make it big and red in Style.
  2. Under Show when, click Pick… and choose health, pick is below, and type 30.
  3. Use the Try values sliders under the screen to see it come and go.

Play it now: the warning shows only when you're nearly out of health.

#4. A pause menu

  1. Click + HUD ▾ ▸ Pause menu. Its buttons are already hooked up.
  2. Click empty space on the screen so nothing is picked. On its HUD card, click Use as pause menu.

Play it now: press Esc. Your menu opens and the game waits.

#5. An inventory screen

  1. Click + HUD ▾ ▸ Inventory screen.
  2. Open Edit ▸ Game Settings… and pick it in Title and screens ▸ Inventory screen.

Play it now: press I to open your inventory screen.

#6. A shake, with code

Code can play an effect on any element of your HUD. In a level script (as in Your first Quick code: Event Player enters the level, a Code node, Run for the whole level):

on("player_hurt", function(amount)
  hud_effect("My HUD", "Health bar", "shake")
end)

Use your HUD's real name (in the list at the top left of the HUD tab) in place of My HUD. Health bar is the element's name in Layers.

Play it now: your bar shakes each time you're hurt.

#Try it yourself

  • Try one of the one-click styles on the HUD card, such as Fantasy Tome, and see every element change.
  • Make a + HUD ▾ ▸ Title menu and click Use as title screen.

#Learn more

#Next

Generated dungeons.