Archived

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

how's this style for animation? lookfing for other ways...

This topic is 5566 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

okey, i have this hammer, which will appear on the middle of the screen... [pre] ------ | | ------ || || || [/pre] okey what i want is, rotates slowly a bit to the right, then after a few secs, rotates very fast to the left and smashes right into the ground! this is how will i do it. hammerTimer == Start timer for hammer's animation... if hammerTimer < 3 seconds then, rotate hammer to the right if hammerTimer > 3 seconds && < 4 seconds then rotate hammer to the left very fast if hammerTimer > 4 seconds && < 10 seconds then display smoke particle effects on ground and fade hammer if hammerTimer > 10 seconds then animation is done, everything should be cleared/faded. how about you? i feel awkward seeing that long list of code in my program.. many thanks [edited by - mickey on September 11, 2002 10:58:20 AM]

Share this post


Link to post
Share on other sites
You could also make a list that would do everything in consecutive order.
Like say; each action lasts for a certain amount of seconds and then goes on to the next one. That way you won''t be skipping animations due to ''time leaks'', but it will only make it appear slower (if there is a time leak).

This is basically how you do it:

while(hammertime < 3)
do animation;

while(hammertime < 4)
do animation;

while(hammertime < 10)
do animation;


As in your example, using ''if'' statements will only make for hard-to-debug errorrs in case the computer somehow screws up with the time count.

-----------------------------
Valkyrias: Tears of Valkyries

Using while loops will lock up the rest of the program, however what biovenger is saying about ''time leaks'' is true. When doing this kind of thing ytou need to be very careful with you greater-than and equal-to-or-greater-than operators. Getting the wrong ones can introdcue very subtle bugs.

I would use basically the original solution, but reverse the order of the if statements, and make them all else if''s.


  
if hammerTimer > 10 seconds
animation is done, everything should be cleared/faded.
else if hammerTimer > 4 seconds
display smoke particle effects on ground and fade hammer
else if hammerTimer > 3 seconds
rotate hammer to the left very fast
else
rotate hammer to the right


Alan

Share this post


Link to post
Share on other sites
mickey, the best way to handle animations like this is to store all the animation data somewhere (a file to be rad, or an array). Tha data is basically a rfame, and a time in mS. Here''s a simple example (in C):


  
typedef struct
{
unsigned char *pBitMap;
unsigned long ulFrameTime;
unsigned long ulStartTime;
} tAnimation;

tAnimation Hammer[NUM_HAMMER_FRAMES];
.
.
.
// check to update frame

if (Hammer[ulCurrentHammer].ulStartTime + Hammer[ulCurrentHammer].ulFrameTime < timeGetTime())
{
// go to next frame and update start time

ulCurrentHammer++;
Hammer[ulCurrentHammer].ulStartTime = timeGetTime();
}

// show the hammer

ShowPicture(Hammer[ulCurrentHammer].pBitMap);
.
.
.


I hope that helps.

Share this post


Link to post
Share on other sites
quote:
Original post by mickey
ahh i see, thanks!

but are all animations like that? based on checking and comparing the time value, if it''s okey i''d like to hear more ways..

jwalker: key frame animation?

thanks!


key frame animation is the type of animation from software like 3dstudio max. Basically, the model is transformed using a series of matrix at a certain time interval.

just like .X file animation



Share this post


Link to post
Share on other sites