Walking Animation

101 views
Skip to first unread message

Jero Mantaring

unread,
Oct 21, 2016, 1:12:00 AM10/21/16
to PuzzleScript
I'm updating a game I made before. I'm trying to create walking animation but I can't get it to work.

What I want to happen:
- Stationary player sprite defaults to PlayerSub.
- Walking vertically alternates the Player_FL and Player_FR sprites.
- Walking to the left alternates Player_LL and Player_LR.
- Walking to the right alternates Player_RL and Player_RR.

The sample I have below is as far as I got. The animation for walking vertically happens, but I'm not moving. Walking to the left freezes the sprite at Player_LL. It moves but is not animated.

I'm afraid that I may have overcomplicated things by having too many elements that I want to work together. I'm not sure though how to simplify this. :\

Any help will be appreciated.

Lukas Schüller

unread,
Oct 21, 2016, 6:02:23 AM10/21/16
to PuzzleScript
Hi,

two problems with your current code:

1. rules like [vertical player] -> [player_blah] will erase the vertical property from the player before movement happens, which is why your character doesn't move. Can be easily fixed by adding a vertical to the right side, i. e. [vertical player] -> [vertical player_blah]

2. your animation is cyclic, which is kind of problematic: if [left player_ll] -> [left player_lr] follows [left player_lr] -> [left player_ll], both rules may be applied on the same turn, meaning you'll get stuck at the player_ll sprite. A useful workaround for this is to use a transparent temp sprite on an extra layer that gets deleted eventually, maybe at the end of the turn (I think this is the standard workaround for this sort of problem).

Fixing both these issues will do most the work, except for defaulting to PlayerSub. I guess what you want to do here is to return PlayerSub if no movement has happened in a while? This seems a lot trickier to implement, but something like this should work:

(Walk Animation)

(Walk Vertical)
[Vertical Player_FL no temp] -> [Vertical Player_FR temp]
[Vertical Player_FR no temp] -> [Vertical Player_FL temp]
[Vertical Player no temp] -> [Vertical Player_FL temp]

(Walk Left)
[Left Player_LL no temp] -> [Left Player_LR temp]
[Left Player_LR no temp] -> [Left Player_LL temp]
[Left Player no temp] -> [Left Player_LL temp]

(Walk Right)
[Right Player_RL no temp] -> [Right Player_RR temp]
[Right Player_RR no temp] -> [Right Player_RL temp]
[Right Player no temp] -> [Right Player_RL temp]

(Start animation timer if player has moved)
late
[Player|temp] -> [Player timer5|]

(No animation timer left? -> Default to PlayerSub)
late
[Player no timer] -> [PlayerSub]

(Countdown timer)
late
[timer1] -> []
late
[timer2] -> [timer1]
late
[timer3] -> [timer2]
late
[timer4] -> [timer3]
late
[timer5] -> [timer4]

... which is even more complicated than what you've started with since it needs 5 extra timer elements (as well as the temp element), but that's the easiest way I can think of which looks decent. Maybe someone else has more experience with animations like this, though.

- Lukas

Lukas Schüller

unread,
Oct 21, 2016, 6:05:02 AM10/21/16
to PuzzleScript
Oops, I've messed up bumping into obstacles, so you would have to add a late [temp] -> [] to the end.
Reply all
Reply to author
Forward
0 new messages