AutoRunnerHUD
The heads-up display for Endless Rampage, drawn in the page over the game.
What it shows
- Top: the score and high score, the free-car clock or your spare cars, the level and distance, speed in km/h and an armour bar. A POLICE badge flashes red and blue under the armour while a patrol car chases you, and NO SCORE counts down while a civilian penalty runs.
- Bottom left: each weapon, what is left of it, and its key. A weapon you try while empty flashes red.
- Middle: messages from the director, points that float up from where a kill happened, a red edge when your car takes a hit of 2 or more, and the cards for the title, pause, game over and the weapons truck.
Use it in a scene
A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.
Build it from scratch with the bjs CLI:
- 1Scaffold a project
World, renderer, and dev server — ready to run.
- 2Install dependencies
- 3Add AutoRunnerHUD
Copies its source into src/ so the scene resolves.
First time? Run bjs login once.
- 4Paste the scene into src/scenes/arcade-room.ts and run
SceneLoader builds the world from the JSON; reload to rebuild.
The HUD is plain page elements over the canvas, so it looks the same under any renderer. Where there is no document, as in tests, it builds nothing.
Numbers on the dash
Three small functions turn raw numbers into what you read:
scoreText(4250) is "004250", the way an arcade cabinet shows it. A score past six digits keeps all of them. clockText(95.2) is "1:36": the clock rounds up, so it reads 0:01 until the free time is truly gone. armorColor(0.5) is amber. Every digit is the same width, so the score does not jitter as it climbs.
All of this comes from autoRunner.status, which the director sends ten times a second. The HUD does no game maths of its own.
Cards and messages
The middle of the screen shows one card at a time, picked by the run's state. On the title card the first word of title is white and the rest takes the accent colour, above the controls list, a START button and PRESS ENTER. Pause shows PAUSED, and game over shows the final score and high score with PLAY AGAIN.
When the car docks in the weapons truck (supplyTruck.docked), a card lists the refits on offer, numbered from 1, with an auto-pick countdown. supplyTruck.upgraded or supplyTruck.released closes it.
START, PLAY AGAIN and a refit card send the same events the keys do: autoRunner.start, or supplyTruck.choose with the card's index. So a phone player can tap where a desktop player types.
Messages are one line at a time, with no queue. A new autoRunner.message replaces the one on screen and restarts the timer with its own seconds.
Settings
| Field | Default | What it does |
|---|---|---|
player | "Player" | The player's car. Damage of 2 or more on it flashes the screen edge red. |
title | "ENDLESS RAMPAGE" | Big title on the start card. The first word is white, the rest is the accent colour. |
subtitle | "ROAD WAR" | Line under the title. |
accent | "#ff4d3d" | CSS colour for the buttons, the free-car glow, the gun pips and the title's second word. |
Events
| Event | Payload | Direction |
|---|---|---|
autoRunner.start | {} | emits, on START or PLAY AGAIN |
supplyTruck.choose | { index } | emits, on a refit card |
autoRunner.status | { state, score, hiScore, lives, freeTime, distance, speed, hp, maxHp, level, penalty, pursuers } | listens |
autoRunner.state.changed | { state, previous } | listens |
autoRunner.score.changed | { score, hiScore, delta, reason } | listens |
autoRunner.message | { text, tone, seconds } | listens |
autoRunner.kill | { entityId, kind, points, x, z } | listens |
autoRunnerWeapons.changed | { entityId, gunLevel, maxGunLevel, missiles, maxMissiles, oil, maxOil, smoke, maxSmoke } | listens |
autoRunnerWeapons.empty | { entityId, weapon } | listens |
health.damaged | { entityId, hp, maxHp, damage } | listens |
supplyTruck.docked | { entityId, truckId, offers, seconds } | listens |
supplyTruck.upgraded | { entityId, offer } | listens |
supplyTruck.released | { entityId, truckId } | listens |
Needs
- AutoRunnerDirector: the run state, score, messages, kills and status the HUD draws.
- AutoRunnerWeapons: the loadout for the weapon rows.
Without a SupplyTruck in the scene the dock card never shows. The rest still works.













































