Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Create
- //self explanatory variable declarations yay!
- rot=0;
- rotSpeed=0;
- radius=64;
- rate=0.0001; // rate of rot increase on collision
- ///Step
- x=centx+lengthdir_x(radius,rot);//weird circle biz
- y=centy+lengthdir_y(radius,rot);//weird circle biz
- 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
- {
- i=0; //failsafe counter
- 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'
- {
- rot+=(rate*sign(rotSpeed); //increment rot by tiny amount
- i+=rate; //increment failsafe
- }
- rotSpeed=0;//stop rotation speed
- }
- rot+=rotSpeed;//increment rot by rotSpeed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement