The game
- Score
- 0
- Missed
- 0
- Time left
- 60s
Press an arrow key to start.
How to play
- Move the basket
- Left and Right arrow keys, or A and D.
- Pause and resume
- P, or the Pause button.
- Play again
- R, or the Play again button.
The game also pauses itself when you switch to another tab, so you never come back to a run that was played without you.
What to read in the code
Open game.js. It is arranged in the order the game happens:
settings, then state, then input, then update(), then
draw(), then the loop that calls those two forever.
-
Nothing is drawn during
update(), and nothing is decided duringdraw(). Keeping those two jobs apart is the single most useful habit in this file. -
Movement is multiplied by
dt, the seconds since the last frame. Without it the game runs at a different speed on a 120 Hz screen than on a 60 Hz one. -
Keys are stored, not acted on. The keydown handler
only records that a key is down;
update()decides what that means. That is why holding a key gives smooth movement.
Change one number in the CONFIG block at the top and reload.
That block exists so you can tune the game without hunting through the
logic for a number that is only used once.