-
-
Notifications
You must be signed in to change notification settings - Fork 60
Anatomy of a frame
During gameplay, the game is in "game session mode". Consequently, the place where everything starts is GameSessionMode::updateAndRender
, which is called from the main loop.
GameSessionMode
's responsibility is to manage level progression, i.e. to start the next level once the current one has finished. As long as we're not done with the current level, we simply call GameRunner::updateAndRender
.
GameRunner
's task is to feed the player's inputs (key or button presses) into the game logic, and to control timing. The game logic runs at a rate of 15 FPS, but rendering runs at the display refresh rate (usually 60 FPS). This means we need to keep track of how much time has elapsed, and call GameWorld::update
if appropriate. All of this happens in GameRunner::World::updateAndRender
.
Independently from updating, we always call GameWorld::render
, which is where the actual rendering takes place.
There is a number of elements making up what you see on screen: The game world itself consists of multiple layers, and then there is the HUD and message display on top. Let's start by having a look at the layers.
The following image shows an animation of the various layers making up RigelEngine's rendering being enabled one by one:
The layers are:
- Parallax background (backdrop)
- Map background
- Sprites
- Map foreground
- Top-level sprites
- Tile debris
- Particles