Assuming you've structured your game logic something like this...
Each fighter uses states for different actions and attack moves i.e.:
Fighter.State == STATE_RUNNING, STATE_ATTACKING, etc...
Fighter.AttackType == ATTACK_DASH, ATTACK_PUNCH, ATTACK_KICK, etc...
... you can check the state and determine an attack from that:
> // someplace that runs every tick
if (Player.State == STATE_RUNNING)
if (KeyDown(KEY_PUNCH))
Player.State = STATE_ATTACKING;
Player.AttackType = ATTACK_DASH;
// reduce movement speed while doing the dash attack
if (Player.State == STATE_ATTACKING && Player.AttackType == ATTACK_DASH)
if (Player.MoveSpeed > 0)
Player.MoveSpeed = Player.MoveSpeed - 0.5*dt;
else
Player.MoveSpeed = 0;
[/code:2ez2pkc9]
Thanks so much, ErekT!
I used Functions and Boolean variables to set the player's mechanics and movements.
Do you think that String variables is more effective?
It's worth emphasizing that my game mixes characteristics of the platform and beat 'em up genres. My character has several abilities such as attack, concentrated attack, combo attack, double jump, run, slide, climb and pick up impulse on the walls.
I confess that I had forgotten to apply the Delta Time to the platform states, but I'll test now.
Soon I'll tell you what happened here.