mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 01:50:44 +01:00
31 lines
656 B
Plaintext
31 lines
656 B
Plaintext
/**
|
|
* Acceleration with Vectors
|
|
* by Daniel Shiffman.
|
|
*
|
|
* Demonstration of the basics of motion with vector.
|
|
* A "Mover" object stores location, velocity, and acceleration as vectors
|
|
* The motion is controlled by affecting the acceleration (in this case towards the mouse)
|
|
*
|
|
* For more examples of simulating motion and physics with vectors, see
|
|
* Simulate/ForcesWithVectors, Simulate/GravitationalAttraction3D
|
|
*/
|
|
|
|
// A Mover object
|
|
Mover mover;
|
|
|
|
void setup() {
|
|
size(640,360);
|
|
smooth();
|
|
mover = new Mover();
|
|
}
|
|
|
|
void draw() {
|
|
background(0);
|
|
|
|
// Update the location
|
|
mover.update();
|
|
// Display the Mover
|
|
mover.display();
|
|
}
|
|
|