Managing Game State
Let’s look at managing state manipulation through the lifetime of the game and creating a shooting stars background.
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()
.
Get hands-on with 1400+ tech skills courses.