Your race car screeches round a sharp corner, tires fighting to keep a grip on the tarmac. You destroy an alien spaceship, watching as it explodes into pieces drifting through space. You’re on the pitch at Wembley and your foot connects with the ball, sending it flying into the back of the net. It’s unlikely you’ve done any of these things in the real world, but they’re all possible in video games, thanks to programmers who bring the on-screen action alive with maths.
Start your engines!
All video games are basically sets of mathematical rules for the computer to follow. It doesn’t matter whether it’s a racing game, a shooter, or a sports game – they’re all full of equations describing everything from the speed of your car to how hard you can kick a ball. These sets of rules are called the game engine, and they control the behaviour of all the characters and objects in a game.
In the early days of video games programmers would create games as a complete package, so the game’s engine couldn’t be separated from content like the character art or the music. It meant starting from scratch for each new game and lead to a lot of repeated work. These days, a game’s engine is usually quite separate from the actual content, allowing it to be reused in many different games. For example, the same engine powers games like Batman: Arkham Asylum and Mirror’s Edge, even though one is a third-person beat ’em up and the other is a first-person platformer. Think of a game as being like a car; different vehicles may vary in shape or colour on the outside, but they’re powered by the same engine hidden underneath.
Under the hood
Car engines are built from separate parts, each with their own job to do. Valves control the flow of fuel, while spark plugs ignite it, and so on. Though companies might use different engine designs, they all need the same parts to work properly, and the same goes for video games. These are just some of the components found in any modern game engine:
- Graphics: Your TV or computer monitor is like a window into the virtual game world. At every moment in time, the game engine has to calculate which parts of the world you can see through the window, using vectors and trigonometry to turn shapes in 3D into shapes on the flat plane of your screen.
- Physics and collisions: All games involve some kind of movement, and that means using physics. It’s impossible to simulate realistic physics at the speed needed for fast-paced video games, so programmers have to find ways to simplify the calculations. They also need to keep track of collisions, so that objects in the game world bounce off each other rather than simply passing through!
- Artificial intelligence: A bunch of dumb enemies all lined up and waiting to be defeated doesn’t make for a very fun game, so programmers give them artificial intelligence, or AI, to create more challenging opponents. The characters aren’t really intelligent though, they’re just following mathematical rules called algorithms that tell them when to move and attack.
- And the rest: The engine also handles the game’s sound, the on-screen text, and any networking if you can play online. Programming all these different parts of the engine requires a good understanding of many different mathematical concepts.
Play to win
Maths is probably the last thing you want to think about when you sit down to play your favourite video game, but if you’d like to make your own games one day, it’s essential. Game engine programmers aren’t the only ones to use maths as well – animators have to deal with triangles and vectors every day. Why not visit Skillset for more information on a career in the games industry?