Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualprushik

Posted 21 October 2012 - 03:19 AM

Hi, I am working on a driving game at the moment, and I am having some serious problems with getting the physics to work right. Not just minor problems, I mean, I am having trouble keeping the numbers from ending up at -NaN within like 5 frames.
I have been following a tutorial that I found here on gamedev.net, but it is written in C#, and I am using C, so I am trying to translate everything into C. The tutorial I am following is here: http://www.gamedev.n...ysics-tutorial/
I did the first part and got what looks like a working rigid body simulator, I could apply a force vector and an offset vector and it moved in a way that looked sane. So I moved on to the rest of the tutorial, and I think I translated all the code pretty well, but then as soon as I ran my executable, everything went crazy.
I spent all of 3 days of free time (not that much with class and both of my jobs) looking for bugs. And I can't seem to find any. I found some discrepancies with the vector math in the tutorial and what I read, so I changed my functions to match the ones on the tutorial, and it almost worked, till I tried to use an angle other than 0.
Oh, I'm also using Linux and SDL2. It should compile easily on Windows if you have SDL2, my code is pretty portable.
Anyways, I'll attach the code, take a look at it and see if you can find any problems with my math. You should probably check my rigid body code, just in case I did something wrong but it just looked right to me.
Thank you in advance, I love you.

EDIT:: I posted updated code. The size is also smaller since I left out some unnecessary images. but the other file (a few posts down) has some code I left out before (accidentally) and includes a makefile so it should be enough to compile if you have SDL2.

#1prushik

Posted 19 October 2012 - 01:55 AM

Hi, I am working on a driving game at the moment, and I am having some serious problems with getting the physics to work right. Not just minor problems, I mean, I am having trouble keeping the numbers from ending up at -NaN within like 5 frames.
I have been following a tutorial that I found here on gamedev.net, but it is written in C#, and I am using C, so I am trying to translate everything into C. The tutorial I am following is here: http://www.gamedev.net/topic/470497-2d-car-physics-tutorial/
I did the first part and got what looks like a working rigid body simulator, I could apply a force vector and an offset vector and it moved in a way that looked sane. So I moved on to the rest of the tutorial, and I think I translated all the code pretty well, but then as soon as I ran my executable, everything went crazy.
I spent all of 3 days of free time (not that much with class and both of my jobs) looking for bugs. And I can't seem to find any. I found some discrepancies with the vector math in the tutorial and what I read, so I changed my functions to match the ones on the tutorial, and it almost worked, till I tried to use an angle other than 0.
Oh, I'm also using Linux and SDL2. It should compile easily on Windows if you have SDL2, my code is pretty portable.
Anyways, I'll attach the code, take a look at it and see if you can find any problems with my math. You should probably check my rigid body code, just in case I did something wrong but it just looked right to me.
Thank you in advance, I love you.

PARTNERS