Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

It's pretty easy to get animations rolling from a sprite sheet. Though which ways there are on combining the animations with player dynamics and motion?

I've figured there's two starting points anyway:

  • Player animation contains motion (the animation slab defines how the sprite moves)
  • Player animation does not contain motion

Simple state machine might do the stuff, but are there alternatives? How would you write the state machine itself for doing it?

I'm writing a small hack&slash&jump platform game in html5. The player should stay in place when he strikes a sword, perhaps even move a bit (one can accomplish it through a hack), but otherwise move pretty much without limits. I've got couple frames and I'd like it all to mesh together well.

share|improve this question
add comment

3 Answers 3

up vote 4 down vote accepted

I prefer to keep animation and motion separate, since it provides for more flexibility.

In my game engine I have a concept called an Action Matrix, which is basically an array of arrays of integers, which are index references into the sprite sheet. Each sub-array is a list of numbers which define the frames of an animation, and each character is assigned an action matrix.

The movement code is hard-wired to use the first four actions for the animation to be played while the character is moving, (in the four cardinal directions,) and beyond that you can create custom animations which can be invoked by playing a different action from the action matrix. These can be used with or without also moving the sprite's position, which is controlled by a separate command.

Also, by playing one of the first four actions in a loop with no movement, you can get a character who seems to be walking in place, or a flying/floating vehicle that just hovers there, or various other other versions of an "idle" animation.

share|improve this answer
    
So you hard code the state machine into your character, then assign animations from a matrix on it. So you've got something like 'jumping', 'falling', 'moving', 'direction', etc. and you just flip the switch when appropriate. That's pretty much what I saw while back ago. –  Cheery Jul 22 '10 at 20:57
    
Maybe there's not alternatives. I'll accept this as an answer. –  Cheery Jul 22 '10 at 20:58
add comment

I like the idea of mimicking the way it is done in 3d games; models, skeletons, and skins. I know of at least one game that made effective use of this idea.

Mommy's Best Games: Weapon of Choice

They released a post mortem afterward and where very happy with their animation editor, Mommy's Best Object Editor.

alt text

You'll have to read the one page description to get the complete understanding, but basically instead of models there are sprites. And the skeletons are only 2D, basically nodes and joints. The animation editor is used to get good looking animations, then the engine tweeks the skeletal animation for added smoothness. Like making sure a monster's feet make good contact wit the ground when it's slanted or uneven.

share|improve this answer
    
that's really cool! In Flash you can use the timeline to make bones animations also. You could spit the timeline info out as xml and use it on any other platform. –  Iain Jul 23 '10 at 14:47
add comment

It's a trade-off. If you encode motion into the anim you can ensure that there's no moonwalking going on, however, by preventing moonwalking you also take away the ability to tweak speeds :o\

I'd definitely prefer having them decoupled so you can change speeds when desired. To prevent moonwalking - defer animation until your gameplay has settled down. Blocks are extremely capable of jumping, running and shooting.

share|improve this answer
    
You answered on the motion, but didn't yet told about alternatives on connecting the player dynamics to the animation. –  Cheery Jul 22 '10 at 20:50
    
True. As for synching animation to dynamics (ie, without moonwalks) I don't really think there's a proper solution with sprite based animations as you can't blend and are stuck with a fixed framerate. If 'no moonwalk' would be a requirement then I would implement the game with blobs and when it's all tweaked to perfection add subblobs for hand and feet and animate those till right and use that as input for a spritesheet. In real life I wouldn't worry about it as Mario got by moonwalking for the past 2 decades without complaints. As for states..I'm oldskool, I'd set the animation per state. –  Kaj Jul 23 '10 at 4:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.