# Week 4-5 random ani­m­a­t­i­o­n­s

• Show Code
``````/** @peep sketch */

int x=0;  // making x=0
int y=0;  // making y=o
int z= (int)random(5); // makes z a random number from 0-9
void setup(){
size(400, 400);
background(255);
};
void draw(){
println(z);
if (z==0) {
if ( x < 200) {
stroke(255, 0, 0);
rect(x, y, x+200, y+200);
rect(x, y+200, x+200, y+400);
x++;
};
if (x == 200){
x=400;
};
if (x > 201) {
stroke(3, 255, 0);
rect(x, y, x+200, y+200);
rect(x, y+200, x+200, y+400);
x--;
};
if (x==201) {
if(y < 200){
rect(x, y, x+200, y+200);
rect(x+200, y, x+200, y+200);
y++;
};
};
if (y == 200){
y=400;
};
if (y > 201){
fill(0, 0, 255);
rect(x, y, x+200, y+200);
y--;
};
if (x==201 && y==201){
noStroke();
rect(x-200, y, x, y+200);
fill(255, 255, 0);

};

if (x==201 && y==201 && frameCount % 50 == 0){
delay(1000);
x=0;
y=0;
background(255);
};

};
if (z==1){
background (random(255), random(255), random(255));
stroke(random(100));
strokeWeight(25);
fill(255,0,0);
line(x, y, x, y);
strokeWeight(15);
fill(255,0,0);
line(x+100, y+100, x+100, y+100);
line(x+200, y+200, x+200, y+200);
line(x+300, y+300, x+300, y+300);
line(x+400, y+400, x+400, y+400);
strokeWeight(15);
fill(255, 0, 255);
rectMode(CORNER);
rect(x+1, y+1, x+1, y+1);
fill(255, 0, 0);
strokeWeight(15);
ellipse(x, y, x, y);
if (++x > 400) {x= -80;}
if (++y > 400) {y= -80;}
if (x < -1) {background(random(255), random(255), random(255));}
if (y < -1) {background(random(255), random(255), random(255));}
fill(255, 0);
rect(0,0,width,height);};
if (z==2){
fill(random(255), random(255), random(255));
rect(pmouseX, pmouseY, random(100), random(100));
};
if (z==3){
fill(random(255), random(255), random(255), random(255));
ellipse (pmouseX, pmouseY, random(150), random(150));
};
if (z==4){
fill(random(255), random(255), random(255));
ellipse (random(400), random(400), 10, 10);
frameRate(1000);
};
if (z==5) {
fill(random(255),random(255),random(255));
rect(50,0,50,400);
rect(0,50,400,50);
rect(150,0,50,400);
rect(0,150,400,50);
rect(250,0,50,400);
rect(0,250,400,50);
rect(350,0,50,400);
rect(0,350,400,50);
};

};``````