ArrayList balls = new ArrayList(); float MUL; void reset(){ balls = new ArrayList(); } void setup(){ size(500,500); MUL = width / 250; ellipseMode(CENTER); frameRate(30); if(console != undefined) { console.log('hi frosty');} } void draw(){ background(0,0,80); for(Ball b : balls){ b.move(); b.draw(); } } void mouseDragged(){ balls.add(new Ball(mouseX,mouseY)); } void mousePressed(){ balls.add(new Ball(mouseX,mouseY)); } void keyPressed(){ if(key == ' '){ balls = new ArrayList(); } } float figureX(float starty,float middle,float radius){ return sqrt(pow(radius,2) - pow(middle - starty,2)); } class Ball{ float x,y; float xspeed; color c = color(255); Ball(float startx, float starty){ float xoff = 0; if(starty > 150 * MUL ){ //bottom ball xoff = figureX(starty, 200 * MUL,50*MUL); } else { if(starty > 90 * MUL){ //middle ball xoff = figureX(starty, 130* MUL,40*MUL); } else { if(starty > 42 * MUL){ //small ball xoff = figureX(starty, 70* MUL,30*MUL); } else { //hat c = color(128); if(starty > 34 * MUL){ //hat brim xoff = 30* MUL; } else { //hat column xoff=10* MUL; } } } } if(startx < width/2){ xoff *= -1; } this.x = width/2 + xoff; this.y = starty; } void draw(){ noStroke(); fill(c); ellipse(x,y,width/30,width/30); } void move(){ if(x< width/2) { xspeed++; } else { xspeed--; } x+=xspeed; } }