Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. /*
  2. declare variables
  3. initialize variables
  4. methods
  5. */
  6.  
  7. class Bubble {
  8. //declare variables
  9. float x;
  10. float y;
  11. float diameter;
  12.  
  13. Bubble() {
  14. //initialize variables
  15. diameter = random(-100, 50);
  16. x = width/2 + random(-200, 200);
  17. y = height-diameter/2;
  18. }
  19. //methods
  20. void display() {
  21. //background(255);
  22. ellipse(x, y, diameter, diameter);
  23. }
  24.  
  25. void ascend() {
  26. y--;
  27. }
  28.  
  29. void top() {
  30. if (y<(diameter/2))
  31. y=diameter/2;
  32. }
  33. }
  34.  
  35. //you can create a new tab at the top of processing
  36. //thats where this code goes
  37. Bubble b1, b2;
  38.  
  39. void setup() {
  40. size(640, 360);
  41. b1 = new Bubble();
  42. b2 = new Bubble();
  43.  
  44. }
  45.  
  46. void draw() {
  47. background(255);
  48. b1.display();
  49. b1.ascend();
  50. b1.top();
  51.  
  52. b2.display();
  53. b2.ascend();
  54. b2.top();
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement