GuillemBarroso / CLing

2D survival game using command line
MIT License
3 stars 1 forks source link

Implement attacking while moving #72

Open GuillemBarroso opened 1 year ago

GuillemBarroso commented 1 year ago

Right now, an attack is triggered by pressing the space bar. When doing so, the player stops moving, the sword image is displayed in front of the player and if the sword image collides with enemies, it deals a certain amount of damage.

The correct implementation would be:

  1. Trigger attack with space bar. Depending on the weapon used, this attack will have:
    • Duration: time that the attack action takes.
    • Angle: degrees that the weapon will travel.
    • Range: weapon distance (along the aiming direction of the player). This is the length of the weapon image.
    • Damage: damage dealt if colliding with an enemy.
    • Speed reduction: speed reduction applied to the player speed.
  2. Display sword image in different positions and angles, so it swings towards the aiming direction of the player.
    • Get the number of frames that the attack action will take using the attack duration.
    • Work out the angles of the weapon at each frame.
    • The sword image should also travel a small distance along the normal to the aiming direction.
    • Display the sword image using the angle and the image position at every frame.
  3. Check for collisions at every frame.
  4. During the attack, the player speed should be reduced using the weapon's speed reduction coefficient.