Guest User

Untitled

a guest
Dec 12th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. PVector pos2 = new PVector();
  2. PVector acc1 = new PVector();
  3. PVector vel1 = new PVector();
  4.  
  5. float grav = 5000;
  6. float mass = 10;
  7.  
  8. boolean aiming = false;
  9.  
  10. void accCalc() {
  11. PVector tempAcc = PVector.sub(pos2, pos);
  12. tempAcc.normalize();
  13. float tempForce = grav*mass/pow(PVector.dist(pos, pos2), 2);
  14.  
  15. tempAcc.mult(tempForce);
  16. acc1.add(tempAcc);
  17. }
  18.  
  19. void gravityControl() {
  20. accCalc();
  21.  
  22. vel1.add(acc1);
  23. vel1.mult(0.3);
  24. pos.add(vel1);
  25. acc1 = new PVector();
  26. acc1.set(0, 0);
  27.  
  28. pushMatrix();
  29. noStroke();
  30. translate(pos2.x,pos2.y);
  31. fill(225);
  32. sphere(50);
  33. popMatrix();
  34. }
  35.  
  36. void draw2() {
  37. gravityControl();
  38. pos2.x = width/2;
  39. pos2.y = height/2;
  40. }
Add Comment
Please, Sign In to add comment