Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


Math and 2D game development


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 PsionicTransvection   Members   -  Reputation: 262

Like
0Likes
Like

Posted 24 March 2012 - 06:08 PM

Hello there sorry for the silly question but I prefer some advices than just going ahead. Recently I started learning how to make simple 2D games.
First one I made was tic tac toe and then I started working on pong but it`s not finished yet. I`m pretty much aware that math is quite an important part of video game development and I just want to ask you guys which branches of mathematics are the most vital ones when it comes to 2D game development .. Let`s say for example a simple side scrolling game with a very basic physics engine. And what math/physics will it be required in order to . let`s say make it smoother and with better physics , sorry again for the lame question it`s just I feel quite confused atm.Really looking forward to your replies !

Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 13659

Like
0Likes
Like

Posted 24 March 2012 - 06:30 PM

For 2D geometric computations in general, knowing your complex numbers in and out can be very helpful.

For Physics, you should learn a bit about how to integrate differential equations numerically (Euler method is the most basic way to do it, and verlet integration is also simple are has some neat properties). It is a difficult subject, but you really need to understand very little of it for a 2D side-scrolling game.

#3 PsionicTransvection   Members   -  Reputation: 262

Like
0Likes
Like

Posted 24 March 2012 - 06:36 PM

Yeah I know that video game development is not easy at all but I have to start from somewhere :)

#4 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 24 March 2012 - 08:47 PM

If you want physics, at the very least, you'll need multivariable calculus and linear algebra.
I trust exceptions about as far as I can throw them.

#5 JTippetts   Moderators   -  Reputation: 8583

Like
1Likes
Like

Posted 24 March 2012 - 08:57 PM

The thing is, you don't really need in-depth knowledge of any given field. You end up cherry-picking a few bits here and there. And like alvaro said, you don't necessarily need to understand it all, as long as you can at least get it functional. Additionally, if you start on a game project of any significant length, there will come a time when you no longer deal with the math at all. Once the framework is done, and you are well into the content generation phase, it is entirely possible that you will forget everything you knew about linear algebra and calculus as regards game development, such that when you start writing the next framework you have to learn it all over again. Happens to me all the time.

Also, don't postpone working on anything until after you feel you know all the math you'll need. Getting a project to work offers a fantastic learning experience to help you pick up the knowledge as you go. You'll go into it a math noob and come out... well, maybe still a noob, but at least a noob with a working 2D game framework under his belt and a better grasp on things than before.

#6 PsionicTransvection   Members   -  Reputation: 262

Like
0Likes
Like

Posted 25 March 2012 - 03:26 AM

can you guys give me a simple example a chunk of code for what complex numbers can be used ?

#7 Álvaro   Crossbones+   -  Reputation: 13659

Like
0Likes
Like

Posted 25 March 2012 - 08:56 AM

I've written code to solve several questions in these forums using complex numbers. https://www.google.com/search?q=std%3A%3Acomplex+alvaro+site%3Agamedev.net

#8 wildbunny   Members   -  Reputation: 550

Like
0Likes
Like

Posted 25 March 2012 - 12:46 PM

I've never used complex numbers in anything I've done in 2d game development.

Here is a maths primer I wrote for game developers: http://www.wildbunny.co.uk/blog/vector-maths-a-primer-for-games-programmers/

It should give you some pointers :)

#9 spooderw   Members   -  Reputation: 123

Like
0Likes
Like

Posted 26 March 2012 - 05:41 PM

Lots of trigonometry.

#10 jwezorek   Crossbones+   -  Reputation: 1924

Like
0Likes
Like

Posted 04 April 2012 - 11:28 AM

Seriously, guys, the answer to the OP's question is trig. To make a 2d side-scrolling game you need to know at least trigonometry. I know the OP mentioned physics but unless we hear otherwise I think we can assume he means very simple physics i.e. how much calculus do you need to implement the physics in a game like Super Mario Bros. 3?

#11 Álvaro   Crossbones+   -  Reputation: 13659

Like
0Likes
Like

Posted 04 April 2012 - 11:55 AM

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.

#12 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 04 April 2012 - 11:59 AM

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.

#13 Álvaro   Crossbones+   -  Reputation: 13659

Like
0Likes
Like

Posted 04 April 2012 - 12:13 PM


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.


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

#14 jwezorek   Crossbones+   -  Reputation: 1924

Like
0Likes
Like

Posted 04 April 2012 - 12:16 PM

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.

#15 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 04 April 2012 - 01:15 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS