Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. float repulsorAngle = atan2(repulsor.y, repulsor.x);
  2. if(rad < 0.0) { angle = map(rad, -PI, 0, 180, 360); }
  3. else { angle = map(rad, 0, PI, 0, 180); }
  4.  
  5. float angleDist = abs(angle - repulsor.angle);
  6. float dist = PVector.dist(new PVector(x, y), new PVector(repulsor.x, repulsor.y));
  7.  
  8. float inc = 45.0;
  9.  
  10. if (angleDist < inc) {
  11. float sine = sin(map(angleDist, inc, 0, 0, PI / 2)) * 50.0;
  12.  
  13. println(sine);
  14.  
  15. x = cos(radians(angle)) * (r + sine * dir);
  16. y = sin(radians(angle)) * (r + sine * dir);
  17.  
  18. } else {
  19.  
  20. x = cos(radians(angle)) * (r);
  21. y = sin(radians(angle)) * (r);
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement