Advertisement
nutter666

Top Down Sword Slashing Code

Jun 2nd, 2014
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var attackRadius:int = 30 // the radial distance from the player that the sword reaches
  2. var attackAngle:int = 80 // the actual angle of the sword slash
  3.  
  4. // within for loop of enemies
  5.  
  6. // check if enemy is close enough for the sword to reach/hit it
  7. If(getDist(enemy,player) <= attackRadius){
  8.  
  9. // calculate if the enemy is within the attackAngle area in front of the player
  10. if(getAngleToObj(player,enemy) <= (player.rotation + attackAngle/2) || getAngleToObj(player,enemy) >= (player.rotation - attackAngle/2) {
  11. // enemy is within slash area, deal damage
  12. }
  13.  
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement