Maths In Games

maths in games zoomed out image of game character

This post and the next few will cover “Maths in Games”.

The idea came to me after talking to different friends about their kids in school and how very little has changed over the years.

When I was their age I used to sit through Math classes wondering why I would ever need to know most of what was being taught, I just wanted to get home and play computer games.

Little did I know how much Math was involved in the very games I played.  It was only years later that I see a lot of algebra and theorems being applied when I started creating my own games.

If games were used to help explain some Math ideas would I have payed a bit more attention in school?  I’d like to think so.

So, to this end, for the next few posts I will take some parts of Maths and show how they are used in games.

Note – I am not demonstrating any code here, just the ideas behind the Maths principles and how I see them applied.


Maths In Games : Intro

Before I go any further, I’m going to assume that you do know the little character you see on your screen when you play a game is not a real person and is not moving around.

It is really a bunch of 1’s and 0’s that translate to colored pixels that are redrawn, giving the impression of animation and movement.

Back in my school days these pixels looked big and clumpy, a series of obvious colored squares.

01 Mario Close Up

Luckily, back then a 50-inch TV screen was unheard of and we had to make do with much smaller screens, with the smaller images and after hours of non-blinking game play we could eventually believe the sets of boxes on screen was a character.

maths in games zoomed out image of game character


For the rest of this post and to make demonstration simpler, the ‘character’ in my examples will be called “hero” and will be a simple rectangle.

Simple rectangle shape for demo of maths in games

The first thing we need to do is place this character on screen, enter “x and y coordinates”.


Maths In Games : X and Y Coordinates

Think of your screen as a blank graph or chart, with an X and Y position.

Normally, the vertical Y Axis starts at zero at the bottom and goes up in numbers.  In the coding for most games I’ve seen, the Y axis starts at zero at the top and the numbers increase the further away from this point.

The horizontal X axis starts at zero from the left hand side and the numbers increase the further away from this point you go.

x and y positions example for maths in games

I’m assigning the x position is the top of the hero character and y is the position of the leftmost side of the character.

Our top character above might be coded as

  • hero.x = 0
  • hero.y = 10

The top of our character is at the top of the screen, zero pixels from the top.  The leftmost side of our character is 10 pixels from the left hand side of our screen.


Our bottom character above might be coded as

  • hero.x = 60
  • hero.y = 60

Our character is 60 pixels from the top of the screen and 60 pixels from the left.

In a basic, very simplified way, that is how we position our character on screen.

At this point, I’d like to remind you that this isn’t a coding lesson and I’m not talking about any particular coding language, so please avoid sending in comments about proper syntax and missing semi colons.

So we now have our character on screen, next we need to move him.


I have now written 4 posts on this topic and found that explaining these ideas might be simpler with an actual demonstration.

Coming soon I will have posts showing you how to create game elements that can be put together to create a game and at the same time see Maths in games yourself.

Click Here to Leave a Comment Below 8 comments

Get every new post delivered to your Inbox

Join other followers:

%d bloggers like this: