PDA

View Full Version : Sprite movement and animation.



Chesso
03-01-2007, 06:11 AM
I borrowed an old gameboy bomberman sprite to test it out in my game.

It just has the Up, Down, Left and Right directions, with 4 frames for each.

The second frame in each direction is the standing still frame.

I'm trying to make it so that when you aren't pushing any keys, like movement or attack keys etc, that it shows just the standing animation (I suppose I could let it Loop a 4 frame standing animation.....).

I use If/Else If/Else If/Else If for checkign IsUp, IsDown, IsLeft and isRight with DXInput for character movement, I then added a Else statement to where I could check which direction the sprite is facing and change it to the standing frame for that direction and tell it not to loop anymore.

Then during processing of Up, Down etc I would set the animation back to looping again and of course fix up the facing and animstart values.

But it only animates this way, if I tap the key, if I hold it in, it gets stuck on one of the walking animations (not the standing point one), which is odd.

So uhh, any ideas? lol.

czar
03-01-2007, 08:22 AM
Probably easier if you posted your code.

Chesso
03-01-2007, 08:59 AM
Well it's been reverted back to normal movement, so it just animates while standing still but I can post that I suppose.

// For Moving our player.
If (isUp In FrmMain.DXInput.States) Then
Begin
Facing := 0; // Facing up.
AnimStart := Up; // Up walking animation.
Y := Y - (300 / 1000) * MoveCount; // Move our sprite up.
End
Else If (isDown In FrmMain.DXInput.States) Then
Begin
Facing := 1; // Facing Down.
AnimStart := Down; // Down walking animation.
Y := Y + (300 / 1000) * MoveCount; // Move our sprite down.
End
Else If (isLeft In FrmMain.DXInput.States) Then
Begin
Facing := 2; // Facing Down.
AnimStart := Left; // Left walking animation.
X := X - (300 / 1000) * MoveCount; // Move our sprite left.
End
Else If (isRight In FrmMain.DXInput.States) Then
Begin
Facing := 3; // Facing Right.
AnimStart := Right; // Right walking animation.
X := X + (300 / 1000) * MoveCount; // Move our sprite right.
End;