Chapter 3: Creating a Game Loop
In the first two chapters, we focused on getting an application built, an environment set up, and graphics on a screen without concerning ourselves with creating an actual functioning game. There's no interactivity here, and no straightforward way to add more characters without copying and pasting more code. In this chapter, that will change, with the addition of a game loop and keyboard events, but first, we're going to need to restructure the code to make it ready for our new features. Be prepared to dig in – this is going to be a busy chapter.
We're going to cover the following:
- Minimal architecture for games
- Creating a game loop
- Adding a keyboard input
- Moving Red Hat Boy
By the end of the chapter, we'll have a mini-game engine that's ready to be extended with new features and process input.