Week 4 Interactive Video 2019



The Grand Budapest Hotel - Funicular

After watching this movie ' The Grand Budapest Hotel', several things I want to do once in my liftime came to my mind. One was spending one week in this hotel, two was having Mendl's cake and three riding the funicular heading to the hotel.

I have tried to make the funicular as an interactive video! If we press key 'g', the funicular goes up, and if twe press key 'b', the funicular goes back down.



CODE


float xpos = 210;
float ypos = 540;

void setup() {
  size(960, 540);
  background(235, 167, 166);
 
}


void draw() {
  //background
  background(235, 167, 166);
 
  strokeWeight(5);
  stroke(220, 160, 160);
  line(0, 50, 960, 50);
  line(0, 100, 960, 100);
  line(0, 150, 960, 150);
  line(0, 200, 960, 200);
  line(0, 250, 960, 250);
  line(0, 300, 960, 300);
  line(0, 350, 960, 350);
  line(0, 400, 960, 400);
  line(0, 450, 960, 450);
  line(0, 500, 960, 500);
  line(330, 0, 330, 50);
  line(450, 0, 450, 50);
  line(570, 0, 570, 50);
  line(690, 0, 690, 50);
  line(270, 50, 270, 100);
  line(390, 50, 390, 100);
  line(510, 50, 510, 100);
  line(630, 50, 630, 100);
  line(330, 100, 330, 150);
  line(450, 100, 450, 150);
  line(570, 100, 570, 150);
  line(690, 100, 690, 150);
  line(270, 150, 270, 200);
  line(390, 150, 390, 200);
  line(510, 150, 510, 200);
  line(630, 150, 630, 200);
  line(330, 200, 330, 250);
  line(450, 200, 450, 250);
  line(570, 200, 570, 250);
  line(270, 250, 270, 300);
  line(390, 250, 390, 300);
  line(510, 250, 510, 300);
  line(330, 300, 330, 350);
  line(450, 300, 450, 350);
  line(270, 350, 270, 400);
  line(390, 350, 390, 400);
  line(330, 400, 330, 450);
  line(270, 450, 270, 500);
 
  //Funicular
  noStroke();
  fill(121, 66, 89);
  rect(xpos+60, ypos, 70, -120);
  rect(xpos+120, ypos-50, 70, -120);
  rect(xpos+180, ypos-100, 70, -120);
 
  fill(228, 185, 158);
  rect(xpos+80, ypos, 30, -100);
  rect(xpos+140, ypos-50, 30, -100);
  rect(xpos+200, ypos-100, 30, -100);
 
  fill(195, 146, 142);
  rect(xpos+55, ypos-130, 65, 10);
  rect(xpos+115, ypos-180, 65, 10);
  rect(xpos+175, ypos-230, 80, 10);
 
  //'g'for go, 'b' for back
  if (keyPressed) {
    if(key=='g'){
      xpos=xpos+0.5;
      ypos=ypos-0.5;
    } else if (key=='b'){
      xpos=xpos-0.3;
      ypos=ypos+0.3;
    }
  }
 
  //Mountain
  fill(167, 116, 115);
  noStroke();
  beginShape();
  vertex(270, 540);
  vertex(750, 540);
  vertex(750, 60);
  endShape(CLOSE);
 
  fill(175, 125, 150);
  beginShape();
  vertex(300, 540);
  vertex(750, 540);
  vertex(750, 90);
  endShape(CLOSE);
 
  //Tunnel
  fill(150, 100, 130);
  rect(650, 350, 200, 200);
  ellipse(750, 350, 200, 200);
 
  translate(-250, 200);
  rect(650, 350, 200, 200);
  ellipse(750, 350, 200, 200);
 
  translate(250, -200);
 
  fill(0);
  rect(0, 0, 210, 540);
  translate(750, 0);
  rect(0, 0, 210, 540);

}

덧글

댓글 입력 영역