Skip to main content
gamedev.net
🔒 Locked

Animate Question

Started by Pintu May 2, 2004 at 6:59 AM 2 replies 600+ views
Original Post
Pintu
Pintu
I want an object to perform a movement when the user presses a key (for example rotating 90 degrees around the y-axis). I code the process like this: I define a bool variable which yields for ''animate'' when TRUE, and (default) ''stop'' when FALSE. When the user presses the key, the bool var is set TRUE, so the animation will start next frame. At the same time, ever frame, the bool variable is controlled whether it''s TRUE or not. If TRUE, the anim starts, a glRotatef function with an angle counter which is increased every frame. And if the (angle==90) the bool variable is set FALSE. This works but I don''t think that it''s a good way to animate things in a big program which has lots of objects doing lots of things. For example if I have possible 50 animations, every frame I control if any of them has been started. Isn''t there a way to tell program the animation only when requested? Some of my friends told me "they use timers". Please tell me a better way. Thanks
Tree Penguin
Tree Penguin
I don''t know if i understood you correctly but people saying ''they do it with timers'' mean they use time-based animations (not frame-based like you do). Anyway, what type of animating is best for your program is something you should find out yourself, look up keyframed animations and armatures (skeletal animation), these are the ones i know of and i think they are used the most.

WWW.TREEPENGUIN.TK
Pintu
Pintu
Thanks for the reply. That''s not the point. I know time based animation/movement. What I ask is about the way that your program calls an animation. Simply, how can I start an animation by just calling it when needed? Instead of controlling all animations at all frames whether they''re started or not.
schue
schue
Your could make 2 Lists, one for the running animations, one for the not running.

If you start an animation, you switch it from the non-running to the running list.

So you only need to go through the list of running animations every frame.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.