Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PVector pos2 = new PVector();
- PVector acc1 = new PVector();
- PVector vel1 = new PVector();
- float grav = 5000;
- float mass = 10;
- boolean aiming = false;
- void accCalc() {
- PVector tempAcc = PVector.sub(pos2, pos);
- tempAcc.normalize();
- float tempForce = grav*mass/pow(PVector.dist(pos, pos2), 2);
- tempAcc.mult(tempForce);
- acc1.add(tempAcc);
- }
- void gravityControl() {
- accCalc();
- vel1.add(acc1);
- vel1.mult(0.3);
- pos.add(vel1);
- acc1 = new PVector();
- acc1.set(0, 0);
- pushMatrix();
- noStroke();
- translate(pos2.x,pos2.y);
- fill(225);
- sphere(50);
- popMatrix();
- }
- void draw2() {
- gravityControl();
- pos2.x = width/2;
- pos2.y = height/2;
- }
Add Comment
Please, Sign In to add comment