Mathematical precision

Mathematics are a particularly important skill in this life. This universal language is an essential tool to understand the world that surrounds us. 

But also, it is indispensable for art and game development. Because you cannot make a videogame without mathematics. The technology behind visual rendering in games relies heavily on algebra and calculus. The graphics processing unit in your computer or home console is specifically designed to be fast at the mathematical transformations necessary to move dots in space, calculating pixel positions in a screen and painting them in the desired color.

But even if you use a game engine that takes care of the most complex rendering issues, as I do, you won’t escape the need to do some math pretty much all the time. 

Take, for example, the simple effect I have been working over the past few hours: A danger anticipation effect that shows some arrows in the screen before a Tetris inspired piece falls, killing the player’s avatar if it is in the way. 

It is a bit crude, but does the trick. I might continue to polish it further. 

The reason to include this in the game is straightforward: Communicating the appearance of an off-screen danger, giving the player enough time to react. In this case, I want the player to know when it is going to happen, how big it’s going to be, and what’s the trajectory it will take.

But one of the difficulties comes in finding the right timing: Make this anticipation too short, and the player won’t know what hit him, causing the game to be frustrating. Make it too long and the challenge will be inexistent. The fact that each player is going to have a different skill level doesn’t make it any easier either!

So, to find that sweet spot you need to be able to iterate fast. Trial and error and a lot of gut feeling. You need to have enough levers to pull: you’d want to control how long it appears before the object is in screen, how fast it appears, how fast the color changes, how it disappears.

And all those levers, surprise, are going to rely on mathematics to exist. In fact, they will be nothing else than parameters in a formula. 

At the end of the day, an effect like this is essentially a change in the size and color of an object. Colors are expressed in vectors, so you can find a formula that is able to adjust the color’s coordinates, knowing the distance and the speed of the falling object. And you’ll want to throw some smooth function over it, so its values don’t change too abruptly.

Axes In Motion shared some of the functions used by their team.

Beautifully expressed in a few lines of code, these arrows fade in, move down, stop, and fade out. And now it is just a matter of playing with the numbers to find the correct balance!

Of course, this is only a tiny bit of the work that is making the simplest of games that it is Sky Diver Classic. Programming, physics, math, art, design, psychology, writing and many other problems are part of the experience of developing any videogame. If you want to develop a game on your own as I’m doing, one has to be able to wear many hats! But it’s all good and fun 🙂

Want to know more about any other game development topics or issues? Leave me a comment and I’ll be happy to write a blog post about it!

Want to try Sky Diver Classic? Here is the link: https://t.co/MDiQYuDTOm?amp=1

Leave a Reply

Your email address will not be published. Required fields are marked *