MrThoe

BubbleHomework

Oct 5th, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. /*MAKE THESE BUBBLES DIFFERENT SIZES AND COLORS */
  2. var bubbles = [];
  3.  
  4. function setup() {
  5. createCanvas(400, 400);
  6.  
  7. }
  8.  
  9. function draw() {
  10. background(220);
  11. for(var i = 0; i < bubbles.length; i++){
  12. bubbles[i].show();
  13. bubbles[i].move();
  14. }
  15. }
  16.  
  17.  
  18. function mouseClicked(){
  19. var b = new Ball();
  20. bubbles.push(b);
  21. }
  22.  
  23. class Ball{
  24. constructor(){
  25. this.x = mouseX;
  26. this.y = mouseY;
  27. }
  28.  
  29. move(){
  30. this.x += random(-2,2);
  31. this.y += random(-2,2);
  32. }
  33.  
  34. show(){
  35. //this.move();
  36. circle(this.x, this.y, 30);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment