Interactive Art_WEEK 5

sehui_woo_week5.zip






/CODE BELOW/


float pigX = 0;
float fin1X = 0;
float fin2X = 0;
float speedP = 3;
float speedF = 4;
float wave1Y = 20;
float wave2Y = 20;
float speed1Y = 0.4;
float speed2Y = 0.4;
PImage sharksfin1;
PImage sharksfin2;

void setup(){
  size(800,450);
sharksfin1 = loadImage("shark_fin_1.png");
sharksfin2 = loadImage("shark_fin_2.png");
}

void draw(){
  
background(#56abf4);
noStroke();
fill(#f0d61e);
rect(0,0,800,100);

pushMatrix();
image(sharksfin1,fin1X,30,180,90);
translate(700,0);
image(sharksfin2,-fin2X,30,180,90);
popMatrix();

stroke(1);
strokeWeight(5);
  
//wave1
stroke(255);
strokeWeight(20);

pushMatrix();
noFill();
translate(0, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(50, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(100, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(150, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(200, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(250, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(300, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(350, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(400, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(450, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(500, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(550, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(600, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(650, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(700, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(750, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(800, wave1Y+50);
rotate(PI/5);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

wave1Y = wave1Y+ speed1Y;
smooth();

if( wave1Y> 40){
  speed1Y = -0.4;
}

if (wave1Y< 0){
  speed1Y = 0.4;
}



//wave2
stroke(#1f5abc);
strokeWeight(5);

pushMatrix();
noFill();
translate(10, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(15, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(70, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(75, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(130, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(135, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(190, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(195, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(250, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(255, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(310, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(315, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(370, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(375, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(430, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(435, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(490, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(495, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(550, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(555, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(610, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(615, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(670, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(675, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(730, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(735, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(790, wave2Y+80);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

pushMatrix();
noFill();
translate(795, wave2Y+90);
scale(1.3);
rotate(PI/8);
beginShape();
vertex(5,40);
bezierVertex(15,50,25,50,40,40);
endShape();
popMatrix();

wave2Y = wave2Y+ speed2Y;
smooth();

if( wave2Y> 40){
  speed2Y = -0.4;
}
if (wave2Y< 0){
  speed2Y = 0.4;
}

//pigggy 
translate(pigX+50,200);
pushMatrix();
stroke (1);
strokeWeight(5);
fill(#4a2c98);
beginShape();
vertex(-40,90);
bezierVertex(0,70,90,70,110,90);
bezierVertex(90,110,0,110,-40,90);
endShape();

fill(#d78b92);
beginShape();
vertex(0,0);
vertex(50,0);
vertex(50,30);
vertex(60,30);
vertex(60,75);
vertex(80,75);
vertex(80,90);
vertex(0,90);
vertex(0,0);
endShape();

beginShape();
vertex(10,0);
vertex(10,10);
vertex(0,10);
endShape();
beginShape();
vertex(40,0);
vertex(40,10);
vertex(50,10);
endShape();
beginShape();
vertex(62,45);
vertex(72,30);
vertex(77,30);
vertex(61,64);
endShape();
beginShape();
vertex(26,50);
vertex(35,60);
vertex(40,60);
vertex(35,50);
endShape();
fill(0);
ellipse(20,10,2,2);
ellipse(30,10,2,2);
noFill();
ellipse(25,28,30,18);
fill(0);
beginShape();
vertex(22,26);
vertex(22,28);
endShape();
beginShape();
vertex(30,26);
vertex(30,28);
endShape();
popMatrix();

pigX = pigX + speedP;
smooth();
if(keyPressed){
  if(keyCode == RIGHT){
    pigX +=  5;
  }else if(keyCode == LEFT){
    pigX -= 5; 
  }
}


if( pigX> 640){
  speedP = -3;
}
if (pigX< -10){
  speedP = 3;
}


//shark's fin 

fin1X = fin1X + speedF;
if (fin1X> 900){
  speedF = -4;
}
if (fin1X< 0){
  speedF = 4;  
}

 fin2X = fin2X + speedF;
if (fin2X> 900){
  speedF = -4;
}
if (fin2X< 0){
  speedF = 4;  
}

}

덧글

댓글 입력 영역