2024-02-18
A game engine is the foundation that a game is built on and often includes many of the tools the game is built with.
At the heart of a game engine is the game loop, which is basically:
while !quitting
While the game is running, we first process any input events. This just needs to read the current state of the inputs we listen to and translate them to game engine terms.
After inputs have been processed, then we update the state of the game. This could include characters making decisions on what to do next, setting the velocity of objects, and advancing the physics simulation of the game.
Once the game state is up-to-date, we can render the next frame to the screen and make sure that the correct sounds are playing.
And that's the basics of how a game engine works!
You may notice that it would be quite cumbersome to make a game on top of this foundation.
Complete game engines have many systems built on top of the basic foundation to simplify the task of creating a game. For example, in Unreal Engine there are systems for menus and games are defined with game modes.
You can explore a simple 2D game engine here.