Permalink
Browse files

Change´ 'loc' references to 'pos' in chp03_oscillation/AttractionArra…

…yWithOscillation
  • Loading branch information...
1 parent ed1c906 commit c3e739ed8052cd8aa4045bce30f1090cc3e2acd8 mlesko committed Sep 18, 2016
@@ -15,7 +15,7 @@ class Attractor {
PVector drag; // holds the offset for when object is clicked on
Attractor(PVector l_,float m_, float g_) {
- loc = l_.get();
+ pos = l_.get();
mass = m_;
G = g_;
drag = new PVector(0.0,0.0);
@@ -27,7 +27,7 @@ class Attractor {
}
PVector attract(Crawler c) {
- PVector dir = PVector.sub(loc,c.loc); // Calculate direction of force
+ PVector dir = PVector.sub(pos,c.pos); // Calculate direction of force
float d = dir.mag(); // Distance between objects
d = constrain(d,5.0,25.0); // Limiting the distance to eliminate "extreme" results for very close or very far objects
dir.normalize(); // Normalize vector (distance doesn't matter here, we just want this vector for direction)
@@ -78,5 +78,4 @@ class Attractor {
}
}
-}
-
+}
@@ -18,7 +18,7 @@ class Crawler {
Crawler() {
acc = new PVector();
vel = new PVector(random(-1,1),random(-1,1));
- loc = new PVector(random(width),random(height));
+ pos = new PVector(random(width),random(height));
mass = random(8,16);
osc = new Oscillator(mass*2);
}
@@ -50,9 +50,8 @@ class Crawler {
fill(175,100);
ellipse(0,0,mass*2,mass*2);
- osc.display(loc);
+ osc.display(pos);
popMatrix();
}
-}
-
+}
@@ -32,6 +32,4 @@ class Oscillator {
line(0,0,x,0);
ellipse(x,0,8,8);
}
-}
-
-
+}

0 comments on commit c3e739e

Please sign in to comment.