Interactive art WEEK 3, homework part 2

For the second part of this week's homework we were tasked with recreating another small animated screenshot from a movie which could interact with the mouse as well as with the keyboard. I decided to use the same movie and create an animation of Toothless flying on his own. below is the result:
The code:


void setup() {
  size(900, 500);

}

void draw (){ 
           if (keyPressed) {              //make it night
    if (key == 'n' || key == 'N')
      background(101, 65, 132);

    }
   
    else {
      background(101, 206, 255);
     
    }
    translate(mouseX, mouseY);
      noStroke();
      fill(60, 49, 45);
        ellipse(0, -5, 170, 90);
        ellipse(300, 30, 450, 100);
       pushMatrix();
        rotate(radians(14));
        rect(30, -53, 135, 80); 
        rotate(radians(20));
        triangle(15, -60, 28, -85, 31, -58);
        triangle(45, -65, 55, -93, 63, -58);
        triangle(70, -70, 78, -98, 85, -80);
        triangle(97, -80, 105, -105, 112, -90);
        triangle(128, -95, 136, -118, 143, -100);
        triangle(150, -110, 158, -140, 165, -115);
        triangle(173, -123, 180, -160, 188, -128);
        triangle(195, -134, 203, -180, 210, -139);
        triangle(219, -155, 225, -200, 232, -161);
        triangle(240, -173, 253, -213, 263, -180);
        triangle(272, -195, 288, -228, 295, -199);
        triangle(302, -210, 312, -242, 320, -213);
        triangle(325, -230, 332, -258, 340, -233);
        triangle(353, -242, 365, -269, 371, -247);
        triangle(378, -255, 387, -280, 395, -260);
       popMatrix(); 
      
       
      fill(168, 146, 105);                                //Eye
      pushMatrix();
      rotate(radians(-10));
        ellipse(-10, -15, 40, 20);
      popMatrix();
      fill(12, 10, 15);
        rect(-28, -23, 18, 22, 7);
       
     
     
      if(mousePressed == true) {          //blinking
        fill(0);
        ellipse(-12, -12, 43, 28);
        fill(60, 49, 45);       
        ellipse(-12, -13, 43, 28);
       
      }
     
      if(mouseY > 250) {
      pushMatrix();                     //wing up
      fill(60, 49, 45);
      stroke(0);
      rotate(radians(20));
        ellipse(280, -285, 85, 400);
      noStroke();
        ellipse(285, -280, 87, 400);
      popMatrix();
                                              //tail up
beginShape();                                            //Tail
        vertex(490, 5);
        vertex(590, -10);
        vertex(630, -20);
        vertex(680, -40);
        vertex(705, -63);
        vertex(713, -80);
        vertex(720, -100);
        vertex(720, -80);
        vertex(715, -59);
        vertex(700, -30);
        vertex(680, -15);
        vertex(640, 10);
        vertex(490, 55);
      endShape(CLOSE);
      pushMatrix();
      rotate(radians(30));
        ellipse(580, -476, 40, 80);
      popMatrix();
        triangle(720, -100, 735, -90, 717, -70);
     
      }
     
       else{
      pushMatrix();                     //wing down
      fill(60, 49, 45);
      stroke(0);
      rotate(radians(-20));
        ellipse(280, 300, 85, 400);
      noStroke();
        ellipse(285, 295, 85, 400);
      popMatrix();
     
      beginShape();                                            //Tail
        vertex(490, 53);
        vertex(590, 68);
        vertex(630, 78);
        vertex(680, 99);
        vertex(705, 121);
        vertex(713, 138);
        vertex(720, 158);
        vertex(720, 138);
        vertex(715, 117);
        vertex(700, 88);
        vertex(680, 73);
        vertex(640, 48);
        vertex(490, 3);
      endShape(CLOSE);
      pushMatrix();
      rotate(radians(20));
        ellipse(720, -65, 40, 80);
      popMatrix();
        triangle(720, 158, 705, 148, 717, 138);
      
       }
      

}

Comments