Which Kinds of Maths Do You Need to Make Video Games?

TIME : 2016-01-07
Which Kinds of Maths Do You Need to Make Video Games?

Game development is split across several disciplines, and every one of them leans on maths to some degree. Programming is the clearest example, because the maths stops being abstract the moment you start writing code.

Maths in an actual render loop

Here's a snippet from Microsoft's XNA framework that builds a 3D primitive:

double angle = MathHelper.TwoPi / points;
pointList = new VertexPositionNormalTexture[points + 1];
pointList[0] = new VertexPositionNormalTexture(
    Vector3.Zero, Vector3.Forward, Vector2.One);

for (int i = 1; i <= points; i++)
{
    pointList[i] = new VertexPositionNormalTexture(
        new Vector3(
            (float)Math.Round(Math.Sin(angle * i), 4),
            (float)Math.Round(Math.Cos(angle * i), 4),
            0.0f),
        Vector3.Forward,
        ...
}

Math.Round does what it says. Math.Sin and Math.Cos are trigonometry: multiply an angle by the radius and you get a coordinate. Feed those coordinates to the graphics pipeline and the console knows exactly where and how to draw the object inside the camera's field of view.

What to study

  • Physics — a game without believable forces feels wrong.
  • Linear algebra — vectors, matrices and transformations are the language of 3D.
  • Algebra 1 and 2 — the working minimum.
  • Geometry — shapes, angles and space.

With those in hand you could write your own engine. If you'd rather license middleware that handles the maths for you, solid algebra is usually enough to get by.

Talk to your course advisor, and be sceptical of anyone who claims you don't need maths to build software. And take a look at raycasting — one afternoon with it makes the case better than any argument.