순수한 젠투펭귄님의 이글루입니다

HannahYUUN.egloos.com


포토로그


interactive video week 5



I've tried to use all of contents we've learned from the sketch_190410a_(2).ziplast lecture.
Press - t  for  dropping tears and filling liquid

Press left and right key to 
move the table

Press mouse button for drinking the liquid (when the straw is in the mouse)


CODE :

PImage righthand;
PImage lefthead;
PImage righthead;
PImage lefthand;
PImage cup;
PImage water;
float tearY = 110;
boolean mousebutton = true;
float waterY = 300;
float waterX1 = 275;
float waterX2 = 400;
float tableX1 = -50;
float tableX2 = 750;
float tableX3 = 550;
float tableX4 = 150;
float righthandX = 580;
float lefthandX = -150;
float cupX = 250;
float cupY = 450;
float waterheight = 150;
float waterup = 320;
float waterX = 260;
void setup ()
{
  size (700, 500);
  
  righthand = loadImage ("righthand.png");
  lefthead = loadImage ("lefthead.png");
  righthead = loadImage ("righthead.png");
  lefthand = loadImage ("lefthand.png");
  cup = loadImage ("cup2.png");
  water = loadImage ("water.png");
}

void draw ()
{
  background (249, 240, 228);
  
  noStroke ();
 
  
  //background
  fill (216, 205, 199);
  beginShape ();
  vertex (200, 0);
  vertex (200, 100);
  vertex (0, 250);
  vertex (0, 0);
  endShape (CLOSE);
  
  beginShape ();
  vertex (500, 0);
  vertex (700, 0);
  vertex (700, 250);
  vertex (500, 100);
  endShape (CLOSE);
   
  fill (224, 214, 209);
  rect (200, 0, 300, 100);
 
  //table
  fill (137, 125, 107);
  beginShape ();
  vertex (tableX1, 550);
  vertex (tableX2, 550);
  vertex (tableX3, 350);
  vertex (tableX4, 350);
  endShape(CLOSE);
  
 
  image (righthand, righthandX, 400);
  image (lefthand, lefthandX, 400);
  image (cup, cupX, 110, 180, 370);
  image (water, waterX, waterup , 135, waterheight);
  
  if (keyPressed && keyCode == LEFT)
  {
    tableX1 = tableX1 -1;
    tableX2 = tableX2 -1;
    tableX3 = tableX3 -1;
    tableX4 = tableX4 -1;
    waterX1 = waterX1 -1;
    waterX2 = waterX2 -1;
    righthandX = righthandX -1;
    lefthandX = lefthandX -1;
    cupX = cupX -1;
    waterX = waterX -1;
    
 
    if (tableX1 <= -150 && tableX2 <= 650)
    {
      tableX1 = -150;
      tableX2 = 650;
      tableX3 = 450;
      tableX4 = 50;
      waterX1 = 200;
      waterX2 = 300;
      righthandX = 480;
      lefthandX = -250;
      cupX = 150;
      waterX = 160;

    }
  }
  
  if (keyPressed && keyCode == RIGHT)
  {
    tableX1 = tableX1 +1;
    tableX2 = tableX2 +1;
    tableX3 = tableX3 +1;
    tableX4 = tableX4 +1;
    waterX1 = waterX1 +1;
    waterX2 = waterX2 +1;
    righthandX = righthandX +1;
    lefthandX = lefthandX +1;
    cupX = cupX +1;
    waterX = waterX +1;
    
    if (tableX1 >= 65 && tableX2 >= 865)
    {
      tableX1 = 65;
      tableX2 = 865;
      tableX3 = 665;
      tableX4 = 265;
      waterX1 = 415;
      waterX2 = 515;
      righthandX = 695;
      lefthandX = -35;
      cupX = 365;
      waterX = 375;
    }
  }
  
  
  //tear
  fill (0);
  circle (184, tearY, 10);
  


  if (keyPressed && keyCode == 't' || keyCode == 'T')
  {
    if (keyCode == 't' || keyCode == 'T')
    tearY = tearY + 4;
    waterheight = waterheight + 0.09;
    waterup = waterup - 0.09;
    
    if (tearY > 300)
    tearY = 110;


    if (waterup < 300)
    waterup = 300;

  }
  else
    tearY = 110;

  image (righthead, 460, -10);
  image (lefthead, -20, -20);

  if (mouseX < 30 || mouseX > 70 && mouseY == 0 || mouseY == 0)
  {
  if (mousePressed)
  {
    if (mousebutton == true);
    tearY = tearY + 2;
    if (tearY > 300)
      tearY = 300;
   }
  }
   
   if (tableX1 >= 65 && tableX2 >= 865)
   {
     if (mousePressed)
     {
       waterheight = waterheight - 0.09;
       waterup = waterup + 0.09;
     }
  }

  
}

덧글

댓글 입력 영역