week 3 homework part 3

int x=100;
int speed=10;
float r, g, b;
void setup() {
size(600, 600);
background(0);
}
void draw(){

r=random(255);
g=random(100);
b=random(200);

fill(255);
rect(0,50,600,100);

fill(0);

 

ellipse(x, 100, 50, 50);
if(x>width) {
speed=speed*-1;
}
else if (x < 0)
speed=speed*-1;

x = x- speed;
}
void mousePressed(){
fill(r,g,b);
rect(300,100,100,600);
rect(0,100,100,600);
rect(150,100,100,600);
rect(450,100,100,600);
}

Print this page
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *