class Ex { float x, y, w, speed, a; Ex (float x_, float y_, float w_, float speed_, float a_) { x = x_; y = y_; w = w_; speed = speed_; a = a_; } void displayx () { noStroke (); fill (126,0,255, a); ellipse (x,y,w,w); } void movex () { if (random(1.0) < 0.5) { x -= speed; y +=speed*0.5; } if (random(1.0) > 0.5) { x -=speed; y -=speed; } x = x + random( - 10,10); y = y + random( - 10,10); x = constrain (x,0,width); y = constrain (y,0,height); a = a + 2 * speed; if (a > 100) { a-=40; } else if (a < 20) { a+=40; } } void bouncex () { if ( y < 1 || y> (height-1) || x < 1 || x > (width-1)) { speed = speed * -0.95; } if ( x < 600 ) { speed = speed *-1; } if (buttonx) { if (random(1.0) < 0.02) { Ex xs = new Ex (random(750,790), random(420,470), random(2,5), random(7), random (150,70)); exes = (Ex []) append (exes, xs); } } } }