Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///Create
  2. //self explanatory variable declarations yay!
  3. rot=0;
  4. rotSpeed=0;
  5. radius=64;
  6. rate=0.0001; // rate of rot increase on collision
  7.  
  8. ///Step
  9. x=centx+lengthdir_x(radius,rot);//weird circle biz
  10. y=centy+lengthdir_y(radius,rot);//weird circle biz
  11.  
  12. if place_meeting(centx+lengthdir_x(radius,rot+rotSpeed),centy+lengthdir_y(radius,rot+rotSpeed),oWall) //check if collision after step at current rotation speed
  13. {
  14.     i=0; //failsafe counter
  15.     while !(place_meeting(centx+lengthdir_x(radius,rot+(rate*sign(rotSpeed)),centy+lengthdir_y(radius,rot+(rate*sign(rotSpeed))),oWall) && i<rotSpeed) //while not colliding when rotated by 'rate'
  16.     {
  17.         rot+=(rate*sign(rotSpeed); //increment rot by tiny amount
  18.         i+=rate; //increment failsafe
  19.     }
  20.     rotSpeed=0;//stop rotation speed
  21. }
  22. rot+=rotSpeed;//increment rot by rotSpeed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement