41 lines
455 B
Plaintext
41 lines
455 B
Plaintext
// The Nature of Code
|
|
// Daniel Shiffman
|
|
// http://natureofcode.com
|
|
|
|
Mover m;
|
|
Attractor a;
|
|
|
|
void setup() {
|
|
size(640,360);
|
|
m = new Mover();
|
|
a = new Attractor();
|
|
}
|
|
|
|
void draw() {
|
|
background(255);
|
|
|
|
PVector force = a.attract(m);
|
|
m.applyForce(force);
|
|
m.update();
|
|
|
|
a.drag();
|
|
a.hover(mouseX,mouseY);
|
|
|
|
a.display();
|
|
m.display();
|
|
|
|
}
|
|
|
|
void mousePressed() {
|
|
a.clicked(mouseX,mouseY);
|
|
}
|
|
|
|
void mouseReleased() {
|
|
a.stopDragging();
|
|
}
|
|
|
|
|
|
|
|
|
|
|