//in class exercise Stripe[] stripes = new Stripe [10]; void setup(){ size(800,500); //initialize all "stripes" for (int j=0; j< stripes.length; j++){ stripes[j] = new Stripe(); } } void draw(){ background(100); //move and display all stripes for(int j=0; j< stripes.length; j++){ //check if mouse is over the Stripe stripes[j].rollover(mouseX, mouseY); stripes[j].move(); stripes[j].display(); } } class Stripe{ float x; float speed; float w; boolean mouse; Stripe(){ x=0; speed = random (1); w= random(10, 30); mouse = false; } //draw stripe void display(){ if (mouse){ fill(255); }else{ fill(255,100); } noStroke(); rect(x,0,w,height); } //move stripe void move(){ x+= speed; if (x>width + 20) x = -20; } //check if point is inside of stripe void rollover(int mx, int my){ //left edge is x, right edge is x+w if ( mx> x && mx < x+ w){ mouse = true; }else{ mouse = false; } } }