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.

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 on other sites
sounds like a finite state machine.

it would work.

or you could use keyframe type animation. but i think your solution is much simpler.

[edited by - jwalker on September 11, 2002 12:14:09 AM]

STOP!

Hammer time.

*groan*

Share on other sites
quote:
Original post by Anonymous Poster
STOP!

Hammer time.

*jwalker remembers old hammer and dances with baggy pants

[edited by - jwalker on September 12, 2002 4:42:48 AM]

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 hammerelse if hammerTimer > 3 seconds    rotate hammer to the left very fastelse    rotate hammer to the right

Alan

Share on other sites
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!

Share on other sites
Yeah, that''s true, While does not do it good enough there. But I still fear else statements. In that case make them multiple if statements, that way time leaks are even less frequent.

-----------------------------
Valkyrias: Tears of Valkyries
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 frameif (Hammer[ulCurrentHammer].ulStartTime + Hammer[ulCurrentHammer].ulFrameTime < timeGetTime()){    // go to next frame and update start time    ulCurrentHammer++;    Hammer[ulCurrentHammer].ulStartTime = timeGetTime();}// show the hammerShowPicture(Hammer[ulCurrentHammer].pBitMap);...

I hope that helps.

Share on other sites
quote:
Original post by Anonymous Poster
STOP!

Hammer time.

ROFL! Too funny (I was thinking the same thing). I like the stop icon too, nice touch.

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

• Forum Statistics

• Total Topics
628635
• Total Posts
2983965

• 10
• 18
• 20
• 13
• 9