Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Particle {
- PVector location;
- PVector velocity;
- PVector acceleration;
- PVector gravity;
- Particle() {
- location = new PVector(width/2, 0);
- velocity = new PVector(0, 0);
- acceleration = new PVector(random(-.3, .3), 0);
- gravity = new PVector(0, 0.01);
- }
- void update() {
- acceleration.add(gravity);
- velocity.add(acceleration);
- location.add(velocity);
- }
- boolean isOutOfBounds() {
- if (location.x > width || location.x < 0 || location.y > height || location.y < 0) {
- return true;
- } else {
- return false;
- }
- }
- void display() {
- pushMatrix();
- translate(location.x, location.y);
- ellipse(0, 0, 20, 20);
- popMatrix();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement