Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


smooth animation and realistic movement

This topic is 6717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i''ve got my 2D engine up and running. the animation is timed perfectly. the way i have it timed is that when a certain amount of time lapses after the last frame was incremented, it increments the frame value and starts the timer over. it works great on my c466, but on my partner''s p133 it runs slow. i''m guessing that the animation misses some of the rollovers and compensates by incrementing the frame late. now what i''m wondering is, would it be a good idea to have a switch statement testing the difference between the last and current times, like this:
case 10: frame = 0; break;
case 20: frame = 1; break;
case 30: frame = 2; break;
and so on... would something like that work correctly? i figure that it would make the right frame show up at the right time... about the movement, on different speed computers (same as the case above) the movement runs faster or slower. is there some way i can factor the time into the animation? also, is there some way i can make the animation more real looking, so the sprite doesn''t look like it''s gliding when it''s supposed to be walking? i''ve tried a switch statement testing the frame number and doing the coordinate calculations from there, but that made the movement jerky... thanks for any help, david

Share this post

Link to post
Share on other sites
If you did it that way, an easier approach may be:

DWORD timeDifference = ... how much time since we checked last ...;
mySprite->frame += (timeDifference/animDelay);
while (mySprite->frame >= maxFrames) mySprite->frame -= maxFrames;

just set animDelay to how fast you want the animation. This assumes that your first frame is 0.

Edited by - Buster on June 27, 2000 1:20:50 PM

Share this post

Link to post
Share on other sites
first you calculate the frame rate that the person is getting on their computer. (without locking the frame rate) then you move the objects in accordance with that rate. you could do it mathmatically or you could us a switch statement.


Share this post

Link to post
Share on other sites
the way that i handle my frame changing right now is almost the same as you posted. i do something like

DWORD difference = current_time - last_time;

if(difference > 100) frame++;
last_time = current_time;

i figure that would work the same. am I wrong?


how would I calculate it matematically? i could probably figure it out myself, but i'm not at my computer at the moment. i'm at work...

thanks guys,

Edited by - neonstar on June 27, 2000 1:33:37 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!