Dash key is pressed -> if dash_flag == false AND stunned == false -> player.dash_flag = true; While player.dash_flag == true -> player.dash_timer += 1; //dash timer is an alterable value If playerdash_flag == true -> player.xVelocity = DASH_VELOCITY*player.direction; //direction = -1 for left, 1 for right -> player.canShoot = false; //check if this flag is true when you try to shoot If player.dash_timer == DASH_TIME -> player.dash_flag = true; -> player.dash_timer = 0; -> player.stunned = true //check if this flag is true whenever the player takes action while player.stunned -> player.stun_timer += 1; //stun_timer is an alterable value if player.stun_timer == STUN_TIME -> player.stunned = false; -> player.stun_timer = 0;