Hello everyone. I am interested in making 2D games on my own, and I would like to know how advanced the math gets if I decide to write my own 2D game engine from scratch instead of using one that already exists.

**0**

# Highest level of math needed for 2D game development?

###
#2
Members - Reputation: **584**

Posted 10 September 2013 - 10:58 PM

Well it depends on whether or not you want to use rotations, or an orthographic camera.

The highest level of math if you want a game with rotations would be trigonometry, however, if you want to use an orthographic camera, you'l need to learn linear algebra to create the matrices.

**Edited by Solid_Spy, 10 September 2013 - 10:59 PM.**

###
#3
Crossbones+ - Reputation: **4951**

Posted 10 September 2013 - 11:06 PM

Well you a mod can merge this thread with this other thread, seeing as they are the same thing.

Beginner in Game Development? Read here.

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts

###
#5
Crossbones+ - Reputation: **6881**

Posted 10 September 2013 - 11:49 PM

Hello everyone. I am interested in making 2D games on my own, and I would like to know how advanced the math gets if I decide to write my own 2D game engine from scratch instead of using one that already exists.

There is no highest level, you can make use of extremely advanced math in a 2D game if you want to.

The lowest level you'd need is just addition and subtraction.

*I don't suffer from insanity, I'm enjoying every minute of it.*

The voices in my head may not be real, but they have some good ideas!

The voices in my head may not be real, but they have some good ideas!

###
#6
Members - Reputation: **-460**

Posted 11 September 2013 - 02:00 AM

Hello everyone. I am interested in making 2D games on my own, and I would like to know how advanced the math gets if I decide to write my own 2D game engine from scratch instead of using one that already exists.

As someone said depends what you do, but sometimes you probably will need to do some more advanced math

I am doing 2d framework and game prototypes and I found a need to do

- mixing rotations and translations on 2d (I can go somewhat lost in it)

- many intersection math for different type of intersection test (it is not so easy at least for me)

- physics by hand and dealing with torque impulse responses etc (can be quite complicated equations)

- you can do probably more complicated especially if you do simulations

You probably also can avoid that when doing more sprite

based games less geometry+physics+simulation ones

###
#7
Crossbones+ - Reputation: **1697**

Posted 11 September 2013 - 08:06 AM

I consider a solid understanding of discrete math to be a necessary skill for any type of programming. If you don't agree, I submit you probably don't know discrete math very well. Learn it, and you'll be enlightened.

I've only just started delving into lambda calculus, but what I have learned so far has drastically improved my productivity and the quality of my code.

If you're interested in anything involving free motion, i.e. an Asteroids clone or an FPS, then trigonometry and linear algebra are important. A solid understanding of differential calculus can significantly enhance your understanding of many problems you might encounter with your update loop as well.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

###
#8
Crossbones+ - Reputation: **16255**

Posted 11 September 2013 - 08:35 AM

You can get away with very little math, as other people have pointed out. However, there are lots of things that are much easier to do if you do know some math.

For 2D graphics, complex numbers are extremely useful: Think of point (x,y) as being the complex number x+y*i. Translation now consist of adding a complex number, rotation consists of multiplying by a unit-length complex number, the rotation to align something to something else is a division of the unit-length complex numbers that represent their attitudes... Your code ends up being extremely compact and easy to get right the first time around.

###
#9
Members - Reputation: **503**

Posted 11 September 2013 - 09:25 AM

I find that, whenever this question is asked, invariably the answers tend to be overblown and overcomplicated. People throw around terms like "lambda calculus" and "linear algebra", but most of it is just to sound impressive and generally the programming only barely touches those concepts on a surface level, if at all.

The truth is, for most game programming (including 3D graphics), if you've gotten your 2nd year of algebra in high school, you'll be fine.

Some concepts can be expressed in multiple ways - and advanced mathematics can just give you another way of thinking about or expressing the details of a problem. For instance, Alvaro suggests complex numbers as being useful to 2D graphics - but he's really just talking about Cartesian coordinates and 2D vectors. Ultimately, in the end, the code is going to end up looking pretty similar no matter which conceptual abstraction you used in your mind to get there

The exception to this rule is if you're planning on writing a physics engine - and at that point, first-year calculus and a year of physics will generally get you all that you need.

An important, related question is - are you good at math? Because if you're really bad at math, you're probably going to have some difficulty. Not because you need the mathematics itself, but because the kind of logical thinking that goes into programming is very similar to the kind of logical thinking that goes into mathematics. So there's going to be some correlation there - if you're good at one, you'll probably be good at the other. And if you're bad at one, you'll probably be bad at the other.

But if you're good at mathematics, even if you don't know a concept important to your work, you'll be able to quickly pick up and learn what you need as you go along.

**Edited by Haytil, 11 September 2013 - 09:26 AM.**

###
#10
Crossbones+ - Reputation: **16255**

Posted 11 September 2013 - 10:06 AM

Some concepts can be expressed in multiple ways - and advanced mathematics can just give you another way of thinking about or expressing the details of a problem. For instance, Alvaro suggests complex numbers as being useful to 2D graphics - but he's really just talking about Cartesian coordinates and 2D vectors. Ultimately, in the end, the code is going to end up looking pretty similar no matter which conceptual abstraction you used in your mind to get there

Not quite. If you are only using additions as translation, I agree. If you start thinking of rotations as unit-length complex numbers instead of angles, that's when using complex numbers simplifies lots of things. You could use Cartesian coordinates and encode rotations as (cos(angle), sin(angle)), and then you'll be basically doing the same thing I suggest.

###
#11
Crossbones+ - Reputation: **3071**

Posted 11 September 2013 - 10:34 AM

I consider a solid understanding of discrete math to be a necessary skill for any type of programming.

plus one that!

apparently, the vast majority of CS / math stuff is discrete mathematics. I was quite surprised when i took the class. i'd already gotten to diff eq's in regular engineering math, but discrete was something "a little different" - quite enlightening.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

###
#13
Crossbones+ - Reputation: **25962**

Posted 11 September 2013 - 10:51 AM

In practice, my math is horrible, and in regular usage of C++ and making 2D games, I don't encounter a need for anything more than addition/subtraction, multiplication/division, occasional powers, and a few other things. I especially find multiplications of decimal numbers useful (*0.1 * 0.5 = 0.05*), and an rudimentary understanding of cartesian coordinates required.

For 2D rotations, you'll have to learn sine, cosine, and tangent, unless your API of choice already handles that for you.

Everyone saying that you need to know alot of math are talking about *ideally*. The more math you know, the better. Learning math actually stretches your mind and literally increases your intelligence. Knowing more math makes solving problems easier.

For 3D programming, more math is needed. For 3D physics, even more math is needed.

Seriously, my math level is about 6th grade or less - about halfway through Algebra 1. On a regular basis, I don't find myself encountering any problems I can't solve, except for tiny problems maybe once every four months or so that I have to stop and think through and then research online how to solve those kinds of problems. Maybe once a year or so I encounter a large problem that I have to figure out.

99% of my challenges are programming challenges, not math-specific challenges. Just jump in and see what you can accomplish, and in the areas you find your knowledge of math falling short, then make a note to improve in that area. When you encounter a challenge, learn how to solve it. After encountering and relearning that challenge two or three times, you'll remember it in the future.

It is very important to know math - but don't let a lack of it scare you away from learning programming. You're asking a forum of math fanatics how much math you need to know. That's like asking a car salesman how expensive a car you need to buy (Salesman *rubbing hands together*: "*How large of a loan can you get?*"). You don't want a junker that gives you problems and constantly needs repair work, but you don't need a mercedes either.

**Edited by Servant of the Lord, 11 September 2013 - 10:59 AM.**

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal | **[Fly with me on Twitter] **

###
#14
Crossbones+ - Reputation: **16255**

Posted 11 September 2013 - 11:24 AM

Now that I think about it, there is one problem that keeps coming up in these forums which does require knowing linear algebra and solving a quadratic equation: Aiming at a moving target with a constant-speed projectile. (Sample thread here)

But really, that's the only example I can think of, and there's a good chance you'll never even encounter it.

###
#15
Members - Reputation: **1827**

Posted 11 September 2013 - 11:54 AM

Addition, subtraction, multiplication, division at a minimum. You'll probably find yourself at a point where you'll need to understand the distance equation (square roots), and some basic trig: sine, cosine, and maybe even arc tangent. You'll be using them more as tools that, while you don't understand how they work, you know how to use them to get done what you need.

**Edited by smr, 11 September 2013 - 11:54 AM.**

###
#16
Crossbones+ - Reputation: **929**

Posted 11 September 2013 - 12:02 PM

I was working on a 2D mobile game where you had to throw an object at a certain rotation depending on the touch input and it would bounce on the walls depending on the angle it collided. I recall having to do a revision on my trigonometry.

**CJ**

====================================

Chesster - the ultimate match-3/puzzle game!

Meme Match

Veggie Snake

Skirmish

###
#17
Crossbones+ - Reputation: **6881**

Posted 11 September 2013 - 12:08 PM

Now that I think about it, there is one problem that keeps coming up in these forums which does require knowing linear algebra and solving a quadratic equation: Aiming at a moving target with a constant-speed projectile. (Sample thread here)

But really, that's the only example I can think of, and there's a good chance you'll never even encounter it.

and if the OP encounters that problem he can just click that link and copy the functions

*I don't suffer from insanity, I'm enjoying every minute of it.*

The voices in my head may not be real, but they have some good ideas!

The voices in my head may not be real, but they have some good ideas!

###
#18
Members - Reputation: **503**

Posted 11 September 2013 - 12:47 PM

People are throwing around the term "linear algebra" when I think they mean "linear equations" (i.e., first year algebra). They are not the same.

You do not need to know "linear algebra" to program games. "Linear algebra" is extremely abstract.

**Edited by Haytil, 11 September 2013 - 12:47 PM.**

###
#19
Crossbones+ - Reputation: **16255**

Posted 11 September 2013 - 12:54 PM

People are throwing around the term "linear algebra" when I think they mean "linear equations" (i.e., first year algebra). They are not the same.

You do not need to know "linear algebra" to program games. "Linear algebra" is extremely abstract.

When I said "linear algebra" in this thread I meant understanding how the dot product works. I suspect others also meant "linear algebra" when they said "linear algebra", as in using matrices to represent linear and affine transformations, which is actually very useful for game programming.