Bash.tv → GitHub → itch.io

Build in-game HUDs for browser games. Health and shield bars with a damage trail and low-health warning, rolling score and coin counters, countdown timers that turn urgent, ammo and lives pips with reload progress, floating damage numbers that merge, off-screen target pointers, safe-area anchors for notches and home bars, readable text on busy backgrounds, layout for desktop and phones, and wha...

Download skill (.zip) Files on GitHub

Game HUD development

The HUD tells the player what they need right now, at a glance, without hiding the game. For the overall look (colors, fonts, layout grid) see game-ui-design.

What goes where

Spot Usually
Top left Health, shield, lives (the player looks here first in Western layouts)
Top center Timer, wave, objective
Top right Score, currency, pause button
Bottom Ammo, abilities, cooldowns. On phones, the thumbs are here: keep the bottom corners for touch controls
Near the player Damage numbers, pickup text, reload ring (the eyes are already there)

Four to six pieces at most. Hide what isn’t changing (full ammo, max health in a calm moment) and show it when it matters.

assets/hud.js

import { createBar, createCounter, createFloaters, countdown, drawPips, lowHealthAlpha, drawVignette, anchors, safeInsets, edgePointer, fmtInt } from "./hud.js";
const hp = createBar({ max: 100 });            // each frame: hp.set(player.hp); hp.update(dt); hp.draw(ctx, x, y, 220, 22, { label: `${hp.value}` })
const score = createCounter();                 // score.set(n); score.update(dt); draw fmtInt(score.shown) at scale 1 + score.pop
const pops = createFloaters();                 // pops.add(-25, x, y, { color: "#ff5a5f", crit }); hits on one spot merge into one number
const cd = countdown(timeLeft, 10);            // { text: "0:08", urgent, pulse }
drawPips(ctx, x, y, { count: ammo, max: 6, reload: reloadProgress });
drawVignette(ctx, W, H, lowHealthAlpha(hp.ratio, time, { reducedMotion }));
const hud = anchors(W, H, safeInsets(scale));  // hud.topLeft(16), hud.bottomRight(16): clear of notches and the home bar
const arrow = edgePointer(objective, camera, view);   // null when on screen, else { x, y, angle } at the edge

Readability

Testing

Check the HUD at 390x844 and 844x390 (game-mobile-testing): nothing under the notch, nothing under the thumbs, nothing clipped. Read it in a screenshot at half size: if you can’t, players can’t either.

Tested

Node tests: bar easing, damage trail wait and drain, heal without trail, clamping; counter rolling; time formats and urgent countdown; floaters merging and expiring; pulsing and steady vignette; safe-area anchors; edge pointer on and off screen; all draw functions run. Used in the UI kit demo (game-menu-system).

Pitfalls

Too much on screen, tiny text on phones, HUD under the notch or thumbs, numbers that jump with no feedback, HUD drawn inside the shaking camera, and important information shown by color only.