Math and 2D game development

Started by
13 comments, last by Storyyeller 12 years ago
Why do you think trigonometry is needed? You can stay away from using angles pretty much all the time, and code tends to be simpler and have fewer special cases when you do.

The jumping in Super Mario Bros. 3 looks like a hack, but the way the response of the controller to horizontal input probably requires some familiarity with calculus. Enough that you can then change the frame rate without affecting the experience too much, for example.
Advertisement

Why do you think trigonometry is needed? You can stay away from using angles pretty much all the time, and code tends to be simpler and have fewer special cases when you do.


Unless of course, you have anything involving rotation or aiming.
I trust exceptions about as far as I can throw them.

[quote name='alvaro' timestamp='1333562116' post='4928257']
Why do you think trigonometry is needed? You can stay away from using angles pretty much all the time, and code tends to be simpler and have fewer special cases when you do.


Unless of course, you have anything involving rotation or aiming.
[/quote]

No, even then you are usually better off using complex numbers or vectors instead.

Why do you think trigonometry is needed? You can stay away from using angles pretty much all the time, and code tends to be simpler and have fewer special cases when you do.

The jumping in Super Mario Bros. 3 looks like a hack, but the way the response of the controller to horizontal input probably requires some familiarity with calculus. Enough that you can then change the frame rate without affecting the experience too much, for example.


Well, I guess it depends on the requirements of the game in question. I was thinking it would be good to know how to get horizontal and vertical components of a vector given an angle for jumping or shooting, say. But, yeah, all of that sort of stuff could obviously be done by defining things in terms of horz and vert offsets rather than angles -- in this case I'd say you need to at least have a solid understanding of algebra.

Look, it wouldn't be bad to have familiarity with calculus but to say that in order to make a relatively simple game you need to know calculus, I mean, I think that is just clearly false.

It depends if the OP is looking for the minimum math needed to get started or for a course of study. If you want to deal with non-trivial physics then you need a background in calculus and so forth. If you want to make something like Super Mario Bros. you need to be comfortable with junior high school level analytic geometry.

No, even then you are usually better off using complex numbers or vectors instead.


Using vectors is usually better, but you can't use them for every purpose. For example, suppose the player can aim in different directions by pressing left and right. You'd expect that pressing left followed by right will leave you facing in the same direction you were before. You can't use a vector because doing so will accumulate rounding errors, so you'll never return to the same position. In that case the only possible representation is an angle.
Basically, for physically simulated rotation, vectors are better, while for rotation that comes directly from the UI, angles are better.

Anyway, I consider udnerstanding of unit vectors and rotation matrices to be trigonometry anyway, so it doesn't really matter.
I trust exceptions about as far as I can throw them.

This topic is closed to new replies.

Advertisement