Advertisement
Guest User

Untitled

a guest
May 25th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. class Particle {
  2. PVector location;
  3. PVector velocity;
  4. PVector acceleration;
  5. PVector gravity;
  6.  
  7. Particle() {
  8. location = new PVector(width/2, 0);
  9. velocity = new PVector(0, 0);
  10. acceleration = new PVector(random(-.3, .3), 0);
  11. gravity = new PVector(0, 0.01);
  12. }
  13.  
  14. void update() {
  15. acceleration.add(gravity);
  16. velocity.add(acceleration);
  17. location.add(velocity);
  18. }
  19.  
  20. boolean isOutOfBounds() {
  21. if (location.x > width || location.x < 0 || location.y > height || location.y < 0) {
  22. return true;
  23. } else {
  24. return false;
  25. }
  26. }
  27.  
  28. void display() {
  29. pushMatrix();
  30. translate(location.x, location.y);
  31. ellipse(0, 0, 20, 20);
  32. popMatrix();
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement