Animation
I realize that to animate something, you need to take the object''s state, update it, and blit the next frame of animation of that object.
However, if this was done every single frame at the usual 60fps, the animation would go so fast that you wouldn''t be able to even tell that the sprite is being animated.
How would you control this? Start a second timer besides the one that keeps the frame rate at a reasonable rate? If so, how it I update the frame of the sprite every so frames? Thanks in advance.
"Remember, I'm the monkey, and you're the cheese grater. So no fooling around."
-Grand Theft Auto, London
D:
March 05, 2000 06:48 PM
You give each frame a frame delay. And you have a setup where you can pass the animation class like a set of frame delays for each animation, and when it''s played, it wait a number of cycles equal to the amount you set the frame delay to on each frame, then change to the next frame of animation. In case you need any more specific help just email. steve@dark-shadows.com
I could be really wrong here, but I think that after updating and re-drawing, you sync the framerate by doing Sleep(30). Doing this will keep the animation steady. Please, if I''m wrong, don''t hesitate to tell me because I want to know too 
Martin

Martin
______________Martin EstevaolpSoftware
U could keep the state of the animation in a floating value. And then for each frame u simply add a number less than 1.0 to the state. U will need to cast the state from a floating value to an int value tho.
IPSoftware: your suggestion of animation control would work pretty well, but people generally don''t like when you limit the rendering speed.
A better thing to do would be to have a time variable for every animation, and for every rendering frame check if the animation should be updated. Then you can choose to have it updating every 10 milliseconds or something.
============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
A better thing to do would be to have a time variable for every animation, and for every rendering frame check if the animation should be updated. Then you can choose to have it updating every 10 milliseconds or something.
============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
Sleep(30) will work, however make sure the rendering loop is in it''s own thread or your performance may drop (nothing will happen for 30/1000 of a second every time through the loop)
- Ryan -
When I encountered this problem with my previous engine (it was a 3d one, so I don''t know if this will help you if you''re doing 2d), I setup my animations to use waypoints. Each object in a hierarchy had its own file, and in the file was a list of possible animations. Each animation sequence had a series of waypoints. I would then calculate how large or small my dx,dy, dz increments would be depending on how fast the engine was running the last frame of animation. Of course these approximations were only linear, but they could be easily extended to incorporate splines.
JoeG
JoeG
joeG
March 11, 2000 05:37 PM
the only problem I see with a sleep(30) is if the frame goes slow compared to the rest it still is going to sleep for that time... slowing it down even more...
I think it would be possible to
get time = a....
process frame
get time = b
if a - b < # then
wait #
else
next frame
something like that may allow you to keep a constant frame rate in almost all circumstances even if render time changes.
I think it would be possible to
get time = a....
process frame
get time = b
if a - b < # then
wait #
else
next frame
something like that may allow you to keep a constant frame rate in almost all circumstances even if render time changes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement