mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 01:29:17 +01:00
25 lines
476 B
Plaintext
Executable File
25 lines
476 B
Plaintext
Executable File
class Particle {
|
|
float x, y; // X-coordinate, y-coordinate
|
|
float vx, vy; // X velocity, y velocity
|
|
float radius; // Particle radius
|
|
float gravity = 0.1;
|
|
|
|
Particle(int xpos, int ypos, float velx, float vely, float r) {
|
|
x = xpos;
|
|
y = ypos;
|
|
vx = velx;
|
|
vy = vely;
|
|
radius = r;
|
|
}
|
|
|
|
void update() {
|
|
vy = vy + gravity;
|
|
y += vy;
|
|
x += vx;
|
|
}
|
|
|
|
void display() {
|
|
ellipse(x, y, radius*2, radius*2);
|
|
}
|
|
}
|