### Author Topic: Mathematics for game programming  (Read 465 times)

#### dragomrak

• Newcomer
• Posts: 23
##### Mathematics for game programming
« on: 07. February 2016, 18:26:02 »
Hello,

I tried to understand some code examples and now I got one question, which seems to be rather important for me. What do you think, how much mathematical knowledge I should have to do 2d game programmes. I am really not good in mathematics. Perhaps I undertstand things like the sentence of Pythagoras, but I never would have any idea, that I have to use it in a specific situation. And unfortunately I have no idea how sinus, cosinus and so on work. It should be possible to understand it ( ;-) ) but even if I manage to understand that, I would  not have any idea that I have to use it in a specific situation. I think that I have to know all that and - more important -  to know, when I have to use that. But obviously I am the greatest mathematical fool on earth. Mathematical issues don't reach my brain. That might be a problem. Does anybody understand, what I mean?
Regards, Dragomrak

#### B+

• Full Member
• Posts: 178
##### Re: Mathematics for game programming
« Reply #1 on: 07. February 2016, 18:44:01 »
Hi Dragomrak,

We can try a little math course, dialogue if you want.

My guess is that you don't know the difference between radians and degrees for angle measures?

Probably need to get that straightened out first, to use SIN and COS functions because they deal with angles.

On the other hand, the use of SIN and COS, trig functions, is rare especially for those who avoid math and you might get a ways into game programming without that knowledge, just copy someone else code.
« Last Edit: 07. February 2016, 18:59:24 by B+ »

#### dragomrak

• Newcomer
• Posts: 23
##### Re: Mathematics for game programming
« Reply #2 on: 07. February 2016, 19:21:06 »
Hi B+,

many thanks for you offer to start a little maths course. That touches my problem exactly.  If you say, that trig functions are rare then I can try to learn the rest but if I come to the point, where I need them I would even not recognize that I need them. I read some tutorials and books regarding game programming, but there always routines, where I need them. So in this case I have to use some else code. That could be a solution. Perhaps I should try text games. ;-)

Regards, Dragomrak

#### B+

• Full Member
• Posts: 178
##### Re: Mathematics for game programming
« Reply #3 on: 07. February 2016, 19:25:08 »
There are all kinds of games. Yes, fun can be yours with text or dialogue type games.

Games can teach too, and in fun way!

#### dragomrak

• Newcomer
• Posts: 23
##### Re: Mathematics for game programming
« Reply #4 on: 07. February 2016, 19:44:29 »
Can I overcome that problem, when I use sprites instead of figures, which I have to draw myself? As far as I understood I can move a sprite on a background and detect kollisions without that stuff. Is that wrong?
Regards, Dragomrak

#### B+

• Full Member
• Posts: 178
##### Re: Mathematics for game programming
« Reply #5 on: 07. February 2016, 20:06:41 »
I am not a sprite expert but as I understand it, moving a sprite around a screen is like moving a rectangle around a screen.

If you can draw rectangles at different points, then you can "draw" sprites at different points on screen.

Collisions of sprites is a matter of one rectangle running into or overlapping another, as I understand the problem.

I hope someone else will correct me, if I am wrong.

#### dragomrak

• Newcomer
• Posts: 23
##### Re: Mathematics for game programming
« Reply #6 on: 07. February 2016, 20:17:14 »
As I understood sprites so far, the are pictures (bmp, jpg...) which are displayed on the screen. You can move them easily and - for example - JB, Blitzbasic or other Basics - have functions to detect collisions. I tried a little game in BlitzBasic, which is a german Basic for 2d game development, some years ago. It displayed some sprites. They jumped around, made noises, beeps and so on and when the have a collision, something happended, points for the enemy, what ever. I did not get very far, but that worked and without any trig function.
Regards, Dragomrak

#### B+

• Full Member
• Posts: 178
##### Re: Mathematics for game programming
« Reply #7 on: 07. February 2016, 20:43:37 »
Yes many gaming dialects have collision detection. Probably ones talked about here at this site have that!