Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. direction_var=point_direction(x,y,mouse_x,mouse_y);
  2.  
  3. if(direction_var > 45 && direction_var <= 135)
  4. global.player_facing_direction = 0;
  5. else
  6. if(direction_var > 135 && direction_var <= 225)
  7. global.player_facing_direction = 1;
  8. else
  9. if(direction_var > 225 && direction_var <= 315)
  10. global.player_facing_direction = 2;
  11. else
  12. if(direction_var >= 315 || (direction_var <= 45 && direction_var >= 0))
  13. global.player_facing_direction = 3;
  14.  
  15. if((direction_var >= 180 && direction_var <= 360))
  16. {
  17.     global.player_animation_y = "S";
  18. }
  19. else
  20. if(direction_var >= 0 && direction_var < 180)
  21. {
  22.     global.player_animation_y = "W";
  23. }
  24.  
  25. if((direction_var >= 270 && direction_var <= 360) || (direction_var >= 0 && direction_var <= 90))
  26. {
  27.     global.player_animation_x = "D";
  28. }
  29. else
  30. if(direction_var > 90 && direction_var < 270)
  31. {
  32.     global.player_animation_x = "A";
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. ////////////////////////////////////////////////////////////////////
  43.  
  44. //ANIMATION SPEED
  45. global.player_animation_speed = 3;
  46.  
  47. //WALKING SPEED
  48. global.player_walking_speed = 5;
  49.  
  50. if keyboard_check(ord("W")) && place_free(x,y-5) {
  51. y-=global.player_walking_speed;
  52. mvkey = "W";
  53. }
  54.  
  55. if keyboard_check(ord("S")) && place_free(x,y+5) {
  56. y+=global.player_walking_speed;
  57. mvkey = "S";
  58. }
  59.  
  60. if keyboard_check(ord("D")) && place_free(x+5,y) {
  61. x+=global.player_walking_speed;
  62. mvkey = "D";
  63. }
  64.  
  65. if keyboard_check(ord("A")) && place_free(x-5,y) {
  66. x-=global.player_walking_speed;
  67. mvkey = "A";
  68. }
  69.  
  70. if(keyboard_check(ord("W"))== false && keyboard_check(ord("S"))== false && keyboard_check(ord("D"))== false && keyboard_check(ord("A"))== false)
  71. {
  72.     global.player_walk_animation = 1;
  73. }
  74. else
  75. {
  76. // WALKING FACING
  77. //Movement Animation
  78. if(mvkey == "W" || mvkey == "S")
  79. {
  80.     if(global.player_animation_y == "W"){
  81.         // up up
  82.         global.player_walk_animation_dir = "W";
  83.         anim += 1;
  84.         if(global.player_animation_speed == anim)
  85.         {
  86.             anim = 0;
  87.         if(global.player_walk_animation == 2)
  88.             global.player_walk_animation = 0;
  89.         else
  90.             global.player_walk_animation += 1;
  91.         }
  92.     }
  93.     else
  94.     if(global.player_animation_y == "S")
  95.     {
  96.         // up down
  97.         global.player_walk_animation_dir = "S";
  98.         anim += 1;
  99.         if(global.player_animation_speed == anim)
  100.         {
  101.             anim = 0;
  102.         if(global.player_walk_animation == 0)
  103.             global.player_walk_animation = 2;
  104.         else
  105.             global.player_walk_animation -= 1;
  106.         }
  107.     }
  108. }
  109. else
  110. if(mvkey == "A" || mvkey == "D")
  111. {
  112.     if(global.player_animation_x == "A"){
  113.         // up up
  114.         global.player_walk_animation_dir = "A";
  115.         anim += 1;
  116.         if(global.player_animation_speed == anim)
  117.         {
  118.             anim = 0;
  119.         if(global.player_walk_animation == 2)
  120.             global.player_walk_animation = 0;
  121.         else
  122.             global.player_walk_animation += 1;
  123.         }
  124.     }
  125.     else
  126.     if(global.player_animation_x == "D")
  127.     {
  128.         // up down
  129.         global.player_walk_animation_dir = "D";
  130.         anim += 1;
  131.         if(global.player_animation_speed == anim)
  132.         {
  133.             anim = 0;
  134.         if(global.player_walk_animation == 0)
  135.             global.player_walk_animation = 2;
  136.         else
  137.             global.player_walk_animation -= 1;
  138.         }
  139.     }
  140. }
  141. }
  142.  
  143.  
  144. ////////////////////////////////////////////////////////////
  145.  
  146. if(global.player_walk_animation_dir = "W")
  147. {
  148.     image_index = 9 + global.player_walk_animation;
  149. }
  150. else
  151. if(global.player_walk_animation_dir = "S")
  152. {
  153.     image_index = 0 + global.player_walk_animation;
  154. }
  155. if(global.player_walk_animation_dir = "A")
  156. {
  157.     image_index = 3 + global.player_walk_animation;
  158. }
  159. if(global.player_walk_animation_dir = "D")
  160. {
  161.     image_index = 6 + global.player_walk_animation;
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement