A matter of state
Before we move on to actually rendering 2D items, we need to add a state machine to our game. Just as we did in RoboRacer2D, we need to be able to handle several different game states: displaying the splash screen, loading resources, displaying the main menu, running the game, pausing the game, and game over.
Tip
Don't let the word state confuse you as it is used in several different ways in computer programming. We just finished a section on render state, learning how to push and pop this state from the OpenGL stacks. Now, we are talking about game state, which you can think of as the different modes that our game is in. A framework that handles different game states is known as a state machine.
Adding the state machine
Fortunately, we will be able to take some of the code directly from RoboRacer2D. Open up RoboRacer2D.cpp
. You can do this from inside the SpaceRacer3D project by clicking File, then Open, and then browsing to RoboRacer2D.cpp
. This will allow you to copy...