Guest User

Untitled

a guest
Jan 22nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //==========
  2. //Create Event: obj_player
  3. //==========
  4.  
  5. rotateAxis = false;
  6. rotateSpeed = 2; //<-- Adjusts speed obj_player circles obj_ball
  7.  
  8.  
  9.  
  10. //==========
  11. //Step Event: obj_player
  12. //==========
  13.  
  14. if (distance_to_object(obj_ball) <= 64)
  15. {
  16. //Distance met, allow rotation.
  17. rotateAxis = true;
  18. }
  19.  
  20.  
  21. if (rotateAxis == true)
  22. {
  23.  
  24.     //If the player has gone too far away from obj_ball, stop allowing rotation.
  25.     if (distance_to_object(obj_ball) >= 70)
  26.     {
  27.     rotateAxis = false;
  28.     //The distance (Currently 70px) is set greater than 64px, as during rotation
  29.     //the distance between objects may increase slightly (Adjust as desired.)
  30.     }
  31.  
  32.    
  33.     //Rotate Around Ball Anti-Clockwise
  34.     if (keyboard_check(ord("S")))
  35.     {  
  36.         //Determine angle between ball and player
  37.         pDirection=point_direction(obj_ball.x,obj_ball.y,x,y);
  38.         var xn,yn;
  39.        
  40.         //Determine new X and Y positions for current step.
  41.         xn = x - sin(pDirection*pi/180)*rotateSpeed;
  42.         yn = y - cos(pDirection*pi/180)*rotateSpeed;
  43.        
  44.         //Set to new location.
  45.         x = xn;
  46.         y = yn;
  47.     }
  48.  
  49.  
  50.     //Rotate Around Ball Clockwise
  51.     if (keyboard_check(ord("W")))
  52.     {
  53.         pDirection=point_direction(obj_ball.x,obj_ball.y,x,y);
  54.         var xn,yn;
  55.         xn = x + sin(pDirection*pi/180)*rotateSpeed;
  56.         yn = y + cos(pDirection*pi/180)*rotateSpeed;
  57.  
  58.         x = xn;
  59.         y = yn;
  60.     }
  61. }
Add Comment
Please, Sign In to add comment