mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 13:21:07 +01:00
33 lines
462 B
Plaintext
33 lines
462 B
Plaintext
/**
|
|
* Circle Collision with Swapping Velocities
|
|
* by Ira Greenberg.
|
|
*
|
|
* Based on Keith Peter's Solution in
|
|
* Foundation Actionscript Animation: Making Things Move!
|
|
*/
|
|
|
|
Ball[] balls = {
|
|
new Ball(100, 400, 20),
|
|
new Ball(700, 400, 80)
|
|
};
|
|
|
|
void setup() {
|
|
size(640, 360);
|
|
}
|
|
|
|
void draw() {
|
|
background(51);
|
|
|
|
for (Ball b : balls) {
|
|
b.update();
|
|
b.display();
|
|
b.checkBoundaryCollision();
|
|
}
|
|
|
|
balls[0].checkCollision(balls[1]);
|
|
}
|
|
|
|
|
|
|
|
|