|
-
May 13th, 2004, 08:32 AM
#1
Thread Starter
Not NoteMe
Time-based movement
Hi all, i'm moving my objects according to when the last frame was rendered.
I want things to move every 10ms, but on slow computers this won't happen, and on fast computers i want think to move as smoothly as possible.
I'm currently moving objects using this as a way of altering there velocity according to the time passed:
Code:
x*(GetTickCount()-LastThink)/10
where x is the actual velocity, and lastthink is the last time the object moved (the 10 is because i want things based on 10ms).
I think this works ok, but i'm having trouble with acceleration. I'm currently doing this to gradually reduce the speed of my object:This doesn't work, the object slows down faster when i'm on a fast computer (and it's called a lot), but takes ages to slow down on a slow computer (when it's not called as often).
To fix this i tried using this (pow is a funciton calculating is 1st parameter raised to the power of its 2nd parameter.):
Code:
velocity *= pow(0.98f,(float)((GetTickCount()-LastThink)/10))
This doesn't work either unfortunatly. 
Anyone have any ideas??
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|