How computers work.
To understand how game engines work, we must first look at how computers generally work as a collection of systems. Computers work on a principle that can be called “layers of abstract complexity,” which just means that everything in a computer is built on something complicated that’s easy to work with. Literally, a computer is a machine that uses patterns of fluctuating voltages in an electrical signal to do arithmetic, but it would be impossible to do anything on a computer if you had to think about it every time you wanted to build something.
To give them an example of how stupid a computer is, we will try to describe the different levels in the simplest terms: At the bottom of a computer’s hardware is a circuit that is manipulated to change the voltage in the circuit. This circuit passes through transistors that interpret the changing voltages into a predictable signal from either out or in (0 or 1). In this way, the voltage, which looks more like a wave when measured directly, becomes a must-have of 0 and 1 second, interpreted as binary patterns in the above layer. These binary values can be lined up in “words” to form commands that the computer must understand. These commands, in turn, are grouped into processes that can perform even more complicated tasks, such as manipulating memory space and send/receive signals from peripheral devices connected to the computer system. Combine enough processes and you have an operating system that can be programmed to perform miraculous tasks to entertain and educate, light, or delete.
These layers are the foundation of computing, each layer having its own specialties, each building superimposed and working together to make the modern general purpose computer operational. On this pillar of complexity are the high-level languages, the easy-to-read and easy-to-write scripting languages that power web browsers and game engines. Thanks to the abstraction layers, you can tell the game engine to draw a 3D character in a room without worrying about what electrical signal to send to the screen to draw the right pixels.
If you want to know more, people from Computerphile regularly publish videos about how computers work: computer lovers on YouTube.
Components of a modern game engine.
Game engines are complicated sets of components that provide many useful functions for creating games. Unlike general development frameworks like Cocoa Touch (for creating iOS applications) or .NET (for creating Windows applications), game engines are designed specifically for creating games and have all their components organized to do just that, to the detriment of other application forms. To compensate for the lack of simple tools for creating menu bars and widgets, the game engines have optimized graphics engines to be as fast as possible and instead of using standard pop-up windows and system sounds, you get sound engines that place sounds in 3D space.
One of the most important aspects of a game is the ability to play it, so the game engines usually support a number of input types: Keyboard, mouse, gamepad and touch are the most important and all less common input methods (joystick, steering wheel, rollerball, multi-touch) are subsets of them. There are several ways to deal with input, but there are two common means: events and polling.
Input events work by the computer waiting for some form of input (mouse button pressed, keyboard key released, joystick axis changed, touch pressed) and triggering their custom code. This can be combined with a “mapping table” that associates keyboard/controller/mouse buttons with named actions such as “Jump” or “Shoot” so that you can create your code without having to worry about the user wanting to play with a different layout than the one you’re building your game around.
Polling is usually done when it comes to position values, such as the x/y coordinates of the mouse or the tilt of the analog stick of a gamepad. The game engine provides the ability to retrieve the values whenever the developer wishes, and it is up to the developer to respond to changes in these values, whether he moves a character or changes the position of the custom mouse pointer.
Besides, what would a game be without innovative graphics? An important selling point of game engines (especially high-profile ones like CryEngine) is the impressive graphics they can usually combine with simple production. 3D games are based on 3D assets that are usually created in an external 3D rendering program like Maya or Blender and imported into the game engine. Game engines that support many import formats are proud of this fact, so game developers can work in their familiar program and import it into a working game without having to do anything inhuman.
Once the asset is imported, you can add it to the game along with bump maps, mirroring/transculent materials, and shadows to create a credible object. Game Engines also offer a variety of lighting technologies and effects that bring the added assets to life and handle the animation of those assets, including crazy things like fading animations to the transition between run/jump/shoot in a believable way.
Describing all the graphical features that the game engines offer would take thousands of words, but basically all the game engines are there to make their job as simple and straightforward as possible. Developers don’t want to bother with converting their carefully crafted 3D models into cryptic formats or manually creating metadata to display them correctly. Game engines do their best work if the user doesn’t get too much trouble with his practical creative work. This, combined with post-processing effects, terrain and particle effects, means that you can create an entire game world within the game engine by combining assets from different sources.
Sound is an integral part of games, although it is overlooked most of the time. Adding sound effects to games is not as easy as you think, especially with the advent of 3D games.
Sound effects usually don’t just come from the speakers as they were recorded, but most game engines have the ability to place sounds within the 3D world that change the volume depending on where their character is relative to the sound. There are also many ways to improve the realism of a sound by adding pitch modulation and reverberation to give the impression that the sound bounces off the walls of its surroundings. Take, for example, the sound of colliding swords in an open field or in the depths of a dungeon and how it contributes to the athmosphere as the sounds reflect the world around them.
Music and GUI sounds work differently because they are added without regard to a 3D position, but are played as if the sound comes from the player’s head. Of course, the engine must provide the means to adapt the music to the mood of the game, instead of just bringing it to full volume.
It’s been decades since games have started with online multiplayers and we are in the midst of a social gaming phenomenon that wants to connect all their gaming adventures with their friends. This requires just as much logic revolving around communicating with different servers or even other client computers, which is a complete nightmare to handle manually. Fortunately, most modern game engines offer a lot of ready-made components and helper scripts that take over most of the heavy haulage and allow them to work on the responsiveness and fun of the multiplayer instead of worrying about the subtleties of TCP/UDP traffic.
It’s not long ago that realistic physics wasn’t really a selling point for games, with most of them relying on their own crazy interpretation of the laws of physics. Today, there are more than a handful of game engines, the largest being Havok, Box2D and PhysX, interwoven into the game engine to master the complicated mathematics needed to realistically simulate the world.
One thing that needs to be understood is that physics is not an integral part of 3D game world rendering, although modern game engines combine both, so the end user doesn’t need to be aware of the distinction. When you render a cube in a game, it’s just a visual effect, perhaps combined with refraction and bump maps, to make it feel like it really exists in the world, but there’s nothing inherent in the cube that says it has to adhere to physical laws. Physics must be added to the cube in order for it to react to gravity or be pushed/hooted by the user. The cube is given a physical form that may not match the visual form, as well as mass, friction, bounce, and other properties to create an object that can interact with the world around it.
Dealing with physics is a costly process and just adding physical bodies to the objects that need to react is an easy way to make games run faster. This is the reason why you can slide along a row of trees as if they were a flat wall, because the calculation necessary to determine their collision with each individual tree trunk is a waste of time for the game if you should just follow the corridor instead of exploring it.
Graphical user interfaces.
Although they are not really able to create the typical user interface of a Windows program with a menu bar and floating windows, game engines tend to offer at least some rudimentary GUI capabilities. Games tend to have their own custom interface that fits the style of the game, so providing a standard interface isn’t really as important as providing means for developers to create their own custom buttons, dropdowns, sliders, and the like by combining textures, colors, and events.
Different game engines treat the GUI problem differently, with some completely ignoring the problem and the developers having to create the functions manually. That’s not the hardest part, because a GUI is just a list of textures/images that can be clicked or selected with the keyboard/gamepad.
Another big part of the game engines are ready-made scripts that can be attached to objects in the game world. The terminology differs from engine to engine, some use the term “Behaviors”, while others speak of “game objects” that differ from “visual objects”, but in the end it comes down to one simple thing: someone else did the work for you.
Most game engines contain scripts to start a game with the player in a certain position, add and move cameras, start/stop particle generators, manipulate lights, trigger events when a player moves into an area, and a whole bunch of other functions. In some cases, it can be so easy to insert a 3D model into the game world and call it a 3rd-person player character, and the game engine has pre-built scripts to move and animate the character, rotate the camera, and let the world react to the player’s position.
Artificial intelligence is a large part of the scripts/modules/behaviors and is present in almost everything the game engines offer, with the most complicated offering the ability to dictate how characters react by building a tree of behavior nodes instead of writing hundreds of lines of code. The “scripts” provided by a game engine depend on how much it does for you, which can be a big help to get a game done quickly, but can also be a problem if you want to do something outside the provided functions.
Advantages and disadvantages.
One of the biggest advantages of game engines is how they provide developers with tools for developing games so they don’t have to reinvent the wheel. From handling the low graphical optimizations necessary for a good FPS rate to importing popular asset formats, game engines essentially do the “routine work” of game development so developers can focus on the atmosphere, the story, and other factors that are important for a good game.
This is also one of the biggest drawbacks of the game engines, as they homogenize the games being built. A game engine for first-person shooters may not be the best for a racing RPG, and their choice of engine may end up hindering their creative expression. A typical example is that all Unreal Engine 3 games have the same visual “feel”, despite different styles, and that they all struggle with texture pop and sound effects due to the technical limitations of the engine itself.
But in the end it doesn’t matter, because game engines offer something that is absolutely necessary in the modern world of desktop/mobile/console gaming: platform interoperability. The idea is that you can build the game on one engine and export your game to a variety of platforms, depending on how many the game engine supports. The advantage for developers is difficult to deny, as you create a game once and then make it available on multiple platforms at the push of a button. Whether the game is optimized for this platform (touch vs. controller vs. keyboard) is another question, so the ubiquitous interoperability is a double-edged sword that can lead to horrible posts if left in numb hands.
Game engines are great! They give developers tools to create games quickly and efficiently while hiding the hard parts associated with developing games for different platforms. Even if you’re just aiming to build a game for a particular platform, game engines can give you a boost that will bring your game out faster and with more features than if you built it from scratch.
Thank you for visiting.