Erick Asadobay H.W 4.1

int cx=10;
int cy=10;
int cw=100;
int ch=100;
int x=150;
int y=150;
int x1=150;
int y1=150;
int w=100;
int h=100;
int w1=100;
int h1=100;
int speed=2;
int state=0;
boolean rec=false;
boolean rac=false;
boolean sun=false;

void setup() {
size(400, 400);
}
void draw() {
if (state == 0) {
background(255);
}
else if (state == 1) {
background(255, 0, 0);
}
else if (state == 2) {
background(0, 255, 0);
}
else if (state == 3) {
background(0, 0, 255);
}
ellipseMode(CORNER);
if (!mousePressed) {
fill(255, 189, 34);
rect(x, y, w, h);
}
else {
fill(0);
ellipse(x, y, w, h);
}
if (rec) {
y=y;
}
else {
y=y + speed;
}

if (y > 300 || y < 0) {
speed = speed * -1;
}
if (mouseX > x && mouseX< x+w && mouseY > y && mouseY < y+h && mousePressed) {
rec=!rec;
}

fill(255, 90, 45, 200);
rect(x1, y1, w1, h1);

if (rac) {
x1=x1;
}
else {
x1=x1 + speed;
}
if (x > 300 || x < 0) {
speed=speed * -1;
}
if (sun) {
fill(255, 255, 0);
ellipse(cx, cy, cw, ch);
}
else {
fill(0);
ellipse(cx, cy, cw, cw);
}
if (mouseX > cx && mouseX < cx+cw && mouseY > cy && mouseY < cy+ch && mousePressed) {
sun=!sun;
}
}

void mousePressed() {
state++;
if (state > 3) {
state=0;
}
}

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published.