Advertisement

velocity question

Started by October 23, 2002 12:22 PM
5 comments, last by Paendrag 22 years ago
I just created my first openGL program program using animation, it is just a circle that bounced around the screen. Anyway, my question is: how do you accuratly model velocity, right now the circle just moves with a velocity in pixels per second, is it possible to model for m/s and then give an accurate gravity of 9.81m/s^2? If this should be in the math forum, I apologize in advance.
I may have misunderstood the question, but why would you do that? Just find good values for speed and gravity that makes it look good.

Like I said, I might have misunderstood this. I''m pretty damn tired right now...

-----------------------------
Reporter: Are they slow-moving, chief?
Sheriff: Yeah, they''re dead. They''re all messed up.
-Night of the living dead
-----------------------------Reporter: Are they slow-moving, chief?Sheriff: Yeah, they're dead. They're all messed up.-Night of the living dead
Advertisement
quote: Original post by Rudan
Like I said, I might have misunderstood this. I''m pretty damn tired right now...


Aren''t we programmers all tired? :D


*Scribble with excessive amounts of loops and curls*
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
quote: Original post by Lektrix
Aren''t we programmers all tired? :D

Indeed. The fact that I''ve been studying all day for my math final doesn''t make it better, either.



-----------------------------
Reporter: Are they slow-moving, chief?
Sheriff: Yeah, they''re dead. They''re all messed up.
-Night of the living dead
-----------------------------Reporter: Are they slow-moving, chief?Sheriff: Yeah, they're dead. They're all messed up.-Night of the living dead
To accurately do velocity all you need is the number of milliseconds since the last frame (using timer code), the previous position of the ball, the direction its going, and how fast its going (sometimes the last two are combined). Pseudo code:

new_x = old_x + velocity_x*milliseconds/1000; //divide by 1000 to get seconds
new_y = old_y + velocity_y*milliseconds/1000;

and to do gravity:

new_velocity_y = velocity_y - 9.8*milliseconds/1000;

See NeHe's framework codes to find timer information and his tutorials on the rest...

Hope that helps a bit

[EDIT] I don't think that last code would work...fixed

[edited by - Thunder_Hawk on October 23, 2002 5:23:32 PM]
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
Thanks, Thunder_Hawk. My main problem is that I have velocity set to 10 pixel/s and gravity at 2 pixels/s^2, I''m accually wondering if it is possible to map this to m/s to make it more readable(and life like). Or shoul I just...
quote: Original post by Rudan
Just find good values for speed and gravity that makes it look good.


I''ll go check out that tutorial now.

Advertisement
quote: Original post by Rudan
Just find good values for speed and gravity that makes it look good.


Heh, shit. Did I write that?
I really shouldn't give any advice when I'm too tired...

-----------------------------
Reporter: Are they slow-moving, chief?
Sheriff: Yeah, they're dead. They're all messed up.
-Night of the living dead

//Edit: Messed up quotes


[edited by - Rudan on October 24, 2002 8:06:55 AM]
-----------------------------Reporter: Are they slow-moving, chief?Sheriff: Yeah, they're dead. They're all messed up.-Night of the living dead

This topic is closed to new replies.

Advertisement