Managing Game State
Explore managing game state in reactive game development with RxJS. Understand how to update and render game content smoothly at 60 frames per second while keeping state changes isolated. Learn techniques to handle multiple moving objects like stars efficiently, balancing purity and performance for consistent gameplay.
We'll cover the following...
Updating game state
Keeping a game’s state in sync with the variety of different events that can happen at any point in the game is quite the challenge. Add the requirement that it all needs to render smoothly at sixty frames per second, and life gets very difficult.
Let’s take a few lessons from the ngrx section in Advanced Angular and add in a canvas flavor to ensure a consistent gameplay experience.
Game state
The initial game state could be seen in gameState.ts where we’re using a class so that resetting the game state is as easy as new GameState().
Like ...