17.9.13

ICM Week 2

Sept 17th, 2013.


This week, we were put to the task of creating an interactive sketch. Mine, is of a dark and rainy day. If you push any key, lightning flashes (lightning not pictured below). When you move the mouse to the left side of the screen, the rain moves away, the sun appears and the sky turns blue. 




The Code:

int x1=100;
int x2=200;
int x3=300;
int x4=350;
int x5=400;
int x6=550;
int x7=625;
float y=0;
float y1=125;
float y2=275;
float y3=420;
float y4=-125;
float g1=random(200,255);
float g2=random(200,255);
float g3=random(190,255);
float b=0;

void setup() {
  size(700, 700);
  stroke(0);
  smooth();
  frameRate(240);
  
}
//lightning
void keyPressed(){
 background(255,255,b);
 frameRate(40);
 }

void draw() {
   background(0,0,b);
   frameRate(340);
   strokeWeight(1);
   
  //sidewalk 
  fill(200);
  rect(0,475,700,700);
  stroke(0);
  line(0,475,800,475);
  line(0,675,800,675);
  line(170,475,0,675);
  line(360,475,290,675);
  line(560,475,590,675);
  
  //heart
  fill(255,0,50);
  noStroke();
  ellipse(mouseX-55,300,random(45,50),random(45,50));
  ellipse(mouseX-95,300,random(45,50),random(45,50));
  triangle(mouseX-119, 307, mouseX-31,307,mouseX-75,random(370,377));

  
  //SUN
  fill(255,255,0);
  ellipse(mouseX-645,100,100,100);
  
  //cloud
  fill(g1);
  ellipse(175,50,70,70);
  fill(g1);
  ellipse(150,50,60,50);
  fill(g1);
  ellipse(210,50,50,50);
   fill(g2);
  ellipse(370,65,100,100);
  fill(g2);
  ellipse(345,65,90,80);
  fill(g2);
  ellipse(305,65,60,60);
  fill(g2);
  ellipse(405,65,60,60);
  fill(g3);
  ellipse(550,50,80,70);
  fill(g3);
  ellipse(580,50,60,50);
  fill(g3);
  ellipse(525,49,50,50);
  //RAIN
  frameRate(440);
  fill(220,40);
  ellipse(mouseX+70,y,10,51);
  y=y+.2;
  ellipse(mouseX+130,y,10,51);
  y=y+.5;
  ellipse(mouseX+200,y,10,51);
  y=y+.2;
  ellipse(mouseX+300,y,10,51);
  y=y+.05;
   ellipse(mouseX+400,y,10,51);
  y=y+.02;
   ellipse(mouseX+500,y,10,51);
  y=y+.2;
   ellipse(mouseX+600,y,10,51);
  y=y+.02;
  ellipse(mouseX+80,y1,10,51);
  y1=y1+.2;
  ellipse(mouseX+155,y1,10,51);
  y1=y1+.5;
  ellipse(mouseX+250,y1,10,51);
  y1=y1+.2;
  ellipse(mouseX+350,y1,10,51);
  y1=y1+.05;
   ellipse(mouseX+450,y1,10,51);
  y1=y1+.02;
   ellipse(mouseX+550,y1,10,51);
  y1=y1+.2;
   ellipse(mouseX+650,y1,10,51);
  y1=y1+.02;
  //third row
  ellipse(mouseX+80,y2,10,51);
  y2=y2+.2;
  ellipse(mouseX+155,y2,10,51);
  y2=y2+.5;
  ellipse(mouseX+250,y2,10,51);
  y2=y2+.2;
  ellipse(mouseX+350,y2,10,51);
  y2=y2+.05;
   ellipse(mouseX+450,y2,10,51);
  y2=y2+.02;
   ellipse(mouseX+550,y2,10,51);
  y2=y2+.2;
   ellipse(mouseX+650,y2,10,51);
  y2=y2+.02;
  ellipse(mouseX+70,y3,10,51);
  y3=y3+.2;
  ellipse(mouseX+130,y3,10,51);
  y3=y3+.5;
  ellipse(mouseX+200,y3,10,51);
  y3=y3+.2;
  ellipse(mouseX+300,y3,10,51);
  y3=y3+.05;
   ellipse(mouseX+400,y3,10,51);
  y3=y3+.02;
   ellipse(mouseX+500,y3,10,51);
  y3=y3+.2;
   ellipse(mouseX+600,y3,10,51);
  y3=y3+.02;
  ellipse(mouseX+80,y4,10,51);
  y4=y4+.2;
  ellipse(mouseX+155,y4,10,51);
  y4=y4+.5;
  ellipse(mouseX+250,y4,10,51);
  y4=y4+.2;
  ellipse(mouseX+350,y4,10,51);
  y4=y4+.05;
   ellipse(mouseX+450,y4,10,51);
  y4=y4+.02;
   ellipse(mouseX+550,y4,10,51);
  y4=y4+.2;
   ellipse(mouseX+650,y4,10,51);
  y4=y4+.02;

  if(mouseX>200){
    frameRate(2000);
    b=b+150;
  }else{
    b=b-150;
  }
  if(y1>790){
    y1=y1-height;

}if(y>790){
    y=y-height;

}if(y2>790){
    y2=y2-height;

}
if(y3>790){
    y3=y3-height;

}
if(y4>790){
    y4=y4-height;
}


}