How Game Engines Work?

0
A screenshot from CryEngine tutorial of a video game character running up the mountain.

Screenshot from CryEngine’s tutorial.

In the world of video games, visually appealing the players isn’t always the high priority. No matter how intricate and detailed the art gets in a game, it all boils down to the core component of that particular game, which makes sure everything renders flawlessly on the player’s hardware without any crashes. This core component is called as the game engine. This edition of Geekswipe will shed some light on the subcomponents of a typical game engine and its working process.

Game engine is a framework

A game engine takes care of the graphics rendering, audio playback, AI control, logic, physics simulations, collision modelling, basic automation, garbage collection, API interfacing, and a lot other low-level functions with the help frequently used methods and libraries that are essential for a video game. Also, the game engine not only interfaces with all these modules in real-time but also manages and optimizes the memory as the game progresses. So it is basically a complex set of simple and constant functions that can be reused. In other words, it is a template or a framework for building games.

Working

Let’s take a relatively modest game like Empire Earth example. The game has multiple layers in it that work together to render what you see on the screen. The graphical assets are usually the character models, object models, textures for these models, sound, music, and maybe some pre-rendered cutscenes.

When a player runs the game, the game engine loads all these assets and game data on to the computer memory. Once everything is loaded, the render engine processes the spatial coordinates of the game objects in real-time to render them on to the screen. In this process, the render engine uses pre-written algorithms and APIs like OpenGL or DirectX to interact with the GPU and map graphical elements on to the objects in real-time. Now the game engine has set the stage for the human player to make his move.

When the player makes a move, the networking component of the engine that has already interfaced with the input hardware (mouse and keyboard) constantly records the input and updates the position. The data would then be used to update the coordinates of the controlled polygons (the character that is being controlled by the player) relative to the game world. The game engine refreshes this data continuously and loops over to update all of its subcomponents with the new data.

The physics engine on the other side works with the stream of data to emulate a realistic response, seamlessly integrating it to the changing dynamics. The audio engine supplements the realism by emulating three-dimensional sounds or effects along with the character movement.

As the game begins to progress, new components like AI would come into play as well. Location-based scripts (saving, checkpoint, cutscenes) would kick in too. New assets will also be loaded based on the variations in the scene.

As all of this is happening, a game engine would also be performing its vital task — optimizing the memory by allocating and deallocating the memory for what needs to be rendered, while still maintaining a continuity by keeping track of all the changes that happen in real-time.

The above process is just a general working of a simple game engine. Modern game engines like Unity or Unreal Engine works in a much more complicated way with a wide class of components and libraries. You can explore the complexity of these game engines, as they are open source and well-documented projects.

This post was first published on February 9, 2014.

Avatar

Karthikeyan KC

Aeronautical engineer, dev, science fiction author, gamer, and an explorer. I am the creator of Geekswipe. I love writing about physics, aerospace, astronomy, and python. I created Swyde. Currently working on Arclind Mindspace.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related