Post: #1
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.
Quote this message in a reply
Post: #2
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.
Quote this message in a reply
Post: #3
In your main game loop ( this may just be your event loop depending on how simple the engine is ):

if( TickCount() > nextAnimationFrame )
     nextAnimationFrame = TickCount() + 2; // This gives us 30 frames per second.

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.
Quote this message in a reply
Post Reply