animation - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Design (/forum-5.html)
+--- Thread: animation (/thread-7701.html)
animation - DrKane - Jun 16, 2002 10:27 PM
I am working on a role-playing engine similar to Exile and have no animation at all. This is my first game and I don't know where or how I should start working on animation.
animation - WFleming - Jun 17, 2002 02:04 AM
You might want to take a look at SpriteWorld if you have no experience. It made my life a whole lot easier on the first game I did. Plus it's free.
animation - kainsin - Jun 17, 2002 10:43 AM
In your main game loop ( this may just be your event loop depending on how simple the engine is ):
Now for the Animate function, you just take all of the sprites that are currently moving and move them a number of pixels equal to the total distance they'll move divided by the total time it'll take them to move that amount.
I.e. you want a sprite to move 32 pixels in 1 second. Well, this means that for every frame the sprite will have to move ( 32 / 30 ) = 1.06667 pixels in one frame. You'll have to round this number as well as keeping track of the number of frames it has already been moving. But this will move the sprite 1 pixel for the first 14 frame, 2 pixels for the 15th frame, 1 pixel for the next 14 frames, and then 2 pixels for the last frame.
Also, you can change the way the sprite looks at certain intervals. If the sprite has 4 frames of animation for this step then the sprite needs to change its picture every ( 30 / 4 ) = 7.5 frames. You can round this off as well, or just check to see if the number of frames the sprite has moved is greater-than-or-equal-to the next time it needs to change appearance.