logo
By Lawrence

11 minutes

Heads-Up Display

Press Enter and a run starts, but only the EventBus panel shows it. Score, spare cars and level are rows of data under Global, and the title screen is a parked car on an empty road. Drive into the weapons truck and its refit menu is still blind, as it has been since lesson 2.4.

This lesson puts all of it on screen, with one component on the Game entity.

Keys and buttons

A phone has no Enter key. So the title card needs a START button, and the truck's menu needs cards you can tap. Now a run can start two ways, and a refit can be picked two ways.

The rule for that is one door in: the key and the button send the same message, and one line in the director reads it.

start = (Enter pressed  or  autoRunner.start heard)  and  (state is title or gameover)

The second half is the lock. It lives in the director, once. Neither the key nor the button knows it is there:

you press      while the run is    the director
Enter          title               starts a run
START          title               starts a run
PLAY AGAIN     gameover            starts a run
Enter          playing             does nothing
Enter          paused              does nothing

The HUD keeps no game of its own. Ten times a second the director sends autoRunner.status, and the HUD draws the last one it heard:

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search