Spaceship Reactive!
To show how we can keep an application pure, we’ll build a video game in which our hero fights endless hordes of enemy spaceships. We’ll make heavy use of Observable pipelines, and I’ll point out along the way when it might be tempting to store state outside the pipeline and how to avoid it.
Video games notoriously keep a lot of external state—scores, screen coordinates for the characters, timers, and so on. Our plan is to build the whole game without relying on a single external variable that keeps state.
In our game, the player will move the spaceship horizontally using the mouse, and will shoot by clicking the mouse or tapping the spacebar. Our game will have four main actors: the moving star field in the background, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access