Beneath all those cool character animations, smart enemies, and fun game mechanics in your favorite games is one thing: math.
Mathematics is the foundation of every game and necessary for everything to work as the designers intended.
This doesn’t just include huge games like Middle Earth: Shadow of Mordor and its enemy-generating Nemesis system.
Even Pac-man employs math to decide how the enemy ghosts move, how long they take to regenerate after being eaten, etc.
Even Pong, arguably one of the simplest games ever made, uses math to dictate the speed of the paddles and movement of the ball.
Math is the Foundation of Game Design
In the same way that math doesn’t work unless you learn and apply the rules, a video game can’t have rules without math. When you think about it, video games are essentially virtual worlds with lots of rules that keep everything working as intended.
No math means Mario keeps floating up after jumping, bullets in Call of Duty shoot in random directions, and even your favorite character in Angry Birds move in inconsistent ways if it moves at all.
Most of the time the math you learned in high school and college is no different than what was used to design a game.
To name a few, some of the common branches of math utilized in game development include:
- Linear Algebra
- Discrete Mathematics
- Applied Mathematics
- And more …
More specific elements of math almost always used in games include:
- Delta time
- Unit and scaling vectors
- Dot and cross products
- And scalar manipulation
Math In Programming
While math is useful even in the art side of game development, it’s the programmers who make use of it to create the characters, mechanics, and more.
Without math, programmers wouldn’t be able to make objects in the game do even the simplest of things, including movement.
Game code combined with variables, vectors, and more is what tells Sonic to run slowly when the player barely presses the D-pad, runs faster when at a full dash, stops completely when he runs into a solid object, and run move differently when underwater.
It’s not hard to see why a game without programming and math would just be a bunch of pretty, useless art.
Together they allow games to simulate our worlds, such as moving water and physics, as well as to deliver something outside real-world possibilities.
Only in Portal can we know what it feels like to step through portals, while only in Halo can we dash at ridiculous speeds to impale a foe with an Energy Sword.
Lifelike water, pathfinding, procedurally generated levels, critical hits, AI that reacts to player input, and even the game engine architecture itself– all of these are not possible for a programmer to do without math.
If you’re considering a career as a game programmer and even designer, expect math to be your greatest tool for creating worlds that players will enjoy thanks to addicting gameplay that not only works as intended but is fun as well.
Does Programming Require Math?
Yes, to a certain degree.
If you want to have a strong sense of control over programming basics, it’s wise to have at least the basic knowledge of math concepts like logic, algebra, and more. You won’t be required to answer complex math problems while coding, but there will most likely be example problems using math equations, and logic.
How Much Math Do I Need To Know To Code?
This depends because not everything in code needs the programmer to take part in the mathematical process. You won’t be solving equations and going into detail. If you are hung up on numbers and problems, the computer can usually figure out those details.
Math in Video Games
Video games and math are basically interchangeable in how enmeshed they are with each other. Every action you do in-game is due to a math calculation of some sort.
Luckily for us, we harness the power of computer programming to cut away all the complicated math that would take hours to complete by hand. Without math, games wouldn’t be what they are.
Running, jumping, flying, diving, surfing, and basically, any physical activity is governed by some sort of school of mathematics.
Everyone knows numbers; they’re what makes our society push onward. The same goes for math in video games. If it weren’t for all of those 1’s and 0’s, we wouldn’t be able to program and create games properly.
This refers to the limits in which certain aspects of gaming have. Discreteness is the opposite of continuous, meaning a neverending set of numbers. In games, we need discreteness to contain and build our game.
Geometry, the field of math that questions the properties, shape, and size of things in a given space, is vital for math in video games. It’s based on right-angled triangles. The geometry makes up nearly all we see in our video games.
You need to have a concept of where an object is in space and time. We do this by using different numbers to label the coordinates, where the object will take space.
This is all about computers repeating themselves. This is a crucial function during the game development process. You can’t have long pauses in gameplay, so you need to split up different portions and make sure they’re all working correctly.
Another huge area of gaming, physics, is the broad field of math in video games. Whether your character is hitting a baseball, jumping over a hedge, or shooting at a target, physics plays one of the most prominent roles in games.
No, these aren’t video game cheat codes. Cheating refers to using shortcuts in the programming process to make our lives a little easier. This is using mathematical functions to simplify hard functions.
Intelligent motion is the many different algorithms used by enemy characters to undertake specific actions in reaction to the player’s presence. Things like acceleration, velocity, and position all affect how enemies react to a target.
As you can probably guess, pitfalls refer to anything in the coding process that can mess up your code and your game. These are accidental mistakes or bugs within the code.
Questions About Math in Programming
What math do you need for video game design?
It’s recommended that you know the basic concepts of geometry, algebra, some trig, and logic. However, this is different for most people and shouldn’t dissuade you from trying if you don’t know more advanced math.
Is coding harder than math?
It depends entirely on the capabilities of the coder. Some find it much more comfortable.
Can you be a programmer if you’re bad at math?
Yes. Coding isn’t as dependent on harder math concepts as you might think. Many examples used in tutorials and books use these more difficult concepts to illustrate how to do something, which could prove to be an issue.
Being better at math helps you understand more advanced concepts and what they represent.
Books About Math and Programming
Math For Programmers
By Paul Orland
This more recent book is filled with fantastic exercises, examples, and helpful math designs to help you net a career in programming.
Orland’s book focuses on exactly what you need to be a successful programmer, data scientist, and machine learning.
Mathematics for Machine Learning
By Marc Peter Deisenroth
This book is geared towards introducing the reader to what mathematical functions are essential to getting the hang of machine learning. These include calculus, algebra, and analytic geometry.
This book aims to more easily blend different flavors of mathematics into one to teach a programmer or computer science student better the basics of machine learning.
A Programmer’s Guide to Computer Science
by Dr. William M Springer II
Dr. Springer sets out to ensure the reader knows their basic math for programming and computer science. You’ll get a crash course in some of the most critical topics, including graphs, problem-solving, complexity theory, and graphs.
Grokking Algorithms: An Illustrated Guide for Programmers
By Aditya Bhargava
This more casual and lighthearted guide will be great for visual learners out there. It sets out to easily convey common problems in programming and how to solve them. This, of course, includes a healthy dash of discrete mathematics.
Through over 400 drawings of detailed walkthroughs, you will be better at math programming by the end.
Doing Math with Python: Use Programming to Explore Algebra, Statistics, Calculus, and More!
By Amit Saha
This is the perfect starting point for those who want to explore the kind of math for programmers with Python. It gives you projects to work on, emphasizing algebra, probability, and calculus.
Math Adventures with Python: An Illustrated Guide to Exploring Math with Code
By Peter Farrell
This fun book on math programming will show you how to best harness the power of math for programming. You will explore mathematical concepts by using the coding language Python.
Foundation Mathematics for Computer Science: A Visual Approach
By John Vince
John Vince dives right into the nitty-gritty of understanding mathematical concepts to better succeed at computer science, and nail math for programming. He blends how it all applies to math, programming, and the real world, illustrating its importance.
Mathematical Structures for Computer Science
By Judith L. Gersting
In this hefty tome, readers will be introduced to the exciting and multifaceted relationship of math programming. With a gentle pace through the chapters, you will feel familiar with the material by the end.
Mathematical Programming: Theory and Methods
By S. M. Sinha
This book covers everything from linear programming to its implementation in our daily lives. Readers will get a clear picture of what the marriage of math and programming is like. There are detailed and challenging proofs for you to explore and hone your skills.
Mathematics & Physics for Programmers
By Danny Kodicek
This guide is aimed at programmers who want to make the most out of mathematical education. This also includes physics for game developers. This is an excellent resource for math programming and has further use for game developers.
Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares
By Stephen Boyd
This intro text to algebra is perfect for math programming. Although it may be a starter text, this outlines all you need to know when programming while using mathematical concepts.
By Gary Chartrand
Chartrand makes the topic of discrete mathematics more accessible. With knowledge of discrete mathematics, calculus, and algebra, you can better apply it to programming. It’s a relaxed and casual read about a denser subject.
An Introduction to Formal Languages and Automata
By Peter Linz
What better way to enhance your programming math skills than by going in-depth with the pillars of computer science? Peter Linz goes smooth on the reader here, not bogging you down with mathematical jargon.
Algorithms Illuminated: Part 1: The Basics
By Tim Roughgarden
Familiarizing the reader with the very essence of computer science, Tim Roughgarden aims to make the reader a better programmer through his excellent guide through algorithms and technical skills.
The Art of Doing Science and Engineering: Learning to Learn
By Richard W. Hamming
This is a more conceptual text aimed at tailoring your thought process towards different problems in logic, math, and programming. This is a fantastic resource to gain scientific inspiration from.