Game Development with raylib C++ — Day #3
Create a Game Loop and Game Class
What makes games different from other applications is that the game must update many times a second for as long as the program runs. This is also known as the “Game Loop”.
The game repeats the following steps:
- Process any inputs
- Update the game world
- Generate any outputs
In this article, we are going to create a Game Class that will encapsulate the logic for this game loop. We are going to build on top of the last project that you can download from here. If you want to learn how to set up VSCode and raylib then go to this article.
Game class files
With the workspace open in VSCode (Visual Studio Code), click on the New file button and create a Game.h and Game.cpp files.
In the header file type the following code that defines the Game class.
In the Game implementation file (cpp), let's start filling out the methods. We need to start with the constructor and deconstructor. At the moment, we will have them doing…