Boost logo

Boost Users :

Subject: [Boost-users] [Statechart] How to model this scenario?
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-11-26 10:28:08


Suppose I have a character in a game. He can run, and do two types of
attacks. He can initiate either an attack first or a jump first, and then
initiate the other second and it will perform both at the same time until
one finishes, then go back to just one until that one is also finished, and
finally go back to just running on the ground. Additionally, he can be
knocked back either on the ground or while already in the air. The system
has the following properties:

- If he is attacking (regardless of whether it be on the ground or in the
air), he cannot initiate another attack until the first one is done.
Otherwise he can always initiate an attack (even in the air).
- If he is jumping, he cannot jump again until the first jump is finished.
- Regardless of whether he is jumping or on the ground, he can initiate
attack 1, initiate attack 2, or jump. All of this is only possible if he is
not currently being knocked back.
- There are separate animations for:
      jumping
      attack 1 while on the ground
      attack 2 while on the ground
      attack 1 while jumping
      attack 2 while jumping
      knockback

If being knocked back, the knockback animation takes priority over whatever
other animation was being played at the time. After the knockback is
complete, it will continue from the previous animation, assuming that state
has not finished.

I feel like I should use some type of concurrent states here, but I'm not
sure how to model the combinatorial factor (i.e. playing different
animations depending on the *combination* of states). I'm also not sure how
to model the priority of the knockback animation. In fact, this is not just
related to the Statechart library, but I'm unclear how to do this using UML
State Machines as well.

Any advice appreciated.
Zach



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net