Files
sunny9898/task8/_ref/noc-examples-processing-master/chp03_oscillation/ExtraOscillatingBody/ExtraOscillatingBody.pde
louiscklaw 5637fbf94f update,
2025-02-01 02:07:58 +08:00

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();
}