Frame Independent Movement
Posted
by
ShrimpCrackers
on Game Development
See other posts from Game Development
or by ShrimpCrackers
Published on 2011-03-09T01:55:23Z
Indexed on
2011/03/09
8:19 UTC
Read the original article
Hit count: 268
frame-rate
I've read two other threads here on movement: Time based movement Vs Frame rate based movement?, and Fixed time step vs Variable time step
but I think I'm lacking a basic understanding of frame independent movement because I don't understand what either of those threads are talking about.
I'm following along with lazyfoo's SDL tutorials and came upon the frame independent lesson. http://lazyfoo.net/SDL_tutorials/lesson32/index.php
I'm not sure what the movement part of the code is trying to say but I think it's this (please correct me if I'm wrong): In order to have frame independent movement, we need to find out how far an object (ex. sprite) moves within a certain time frame, for example 1 second. If the dot moves at 200 pixels per second, then I need to calculate how much it moves within that second by multiplying 200 pps by 1/1000 of a second.
Is that right? The lesson says:
"velocity in pixels per second * time since last frame in seconds. So if the program runs at 200 frames per second: 200 pps * 1/200 seconds = 1 pixel"
But...I thought we were multiplying 200 pps by 1/1000th of a second. What is this business with frames per second?
I'd appreciate if someone could give me a little bit more detailed explanation as to how frame independent movement works.
Thank you.
© Game Development or respective owner