Advertisement
Guest User

Untitled

a guest
Oct 4th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. float r = 10;
  2. ArrayList<Block> blocks=new ArrayList<Block>();
  3.  
  4.  
  5. void setup() {
  6. size(600, 600);
  7. blocks = new ArrayList<Block>();
  8. blocks.add(new Block(200, 200, r));
  9. }
  10.  
  11. void draw() {
  12. background(30);
  13. for (int i = blocks.size() - 1; i >= 0; i--) {
  14. Block block = blocks.get(i);
  15.  
  16.  
  17. block.display();
  18. block.gravi();
  19. block.stope();
  20.  
  21. }
  22. }
  23. void mousePressed() {
  24. blocks.add (new Block(mouseX, mouseY, r));
  25. }
  26.  
  27.  
  28. class Block {
  29. float r = 10;
  30. PVector position;
  31. float grav;
  32. Block(float tempX, float tempY, float tempR ) {
  33. position = new PVector (tempX, tempY);
  34. r = tempR;
  35. grav = 0.5;
  36. }
  37.  
  38. void display() {
  39. rect(position.x, position.y, r, r);
  40. }
  41. void gravi() {
  42. position.y = position.y + grav;
  43. }
  44. void stope() {
  45. if (position.y >= height-r) {
  46. grav=grav*0;
  47. }
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement