Game Development with raylib C++ — Day #3

Create a Game Loop and Game Class

Jean-Noel Seneque
4 min readOct 26, 2021

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:

  1. Process any inputs
  2. Update the game world
  3. 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…

--

--

Jean-Noel Seneque
Jean-Noel Seneque

Written by Jean-Noel Seneque

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com

No responses yet