Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.47 KB | None | 0 0
  1. PShape basePanda, normalPanda, happyPanda, vhappyPanda, sadPanda, vsadPanda, lEar, rEar, Face, lEye, rEye, tlEye, trEye, lPupil, rPupil, lCheek, rCheek, Nose, Eyebrow;
  2. PImage squint, smile, hearts;
  3. int savedTime;
  4. int totalTime = 500;
  5. int grump = 25;
  6. boolean happiness = false;
  7.  
  8.   void setup() {
  9.       size(500, 500, P2D);
  10.       noStroke();
  11.       background(173,236,91);
  12.       ellipseMode(CENTER);
  13.       smooth();
  14.       cursor();
  15.      
  16.       //Imports png images to display
  17.       squint = loadImage("squint.png");
  18.       smile = loadImage("smile.png");
  19.       hearts = loadImage("hearts.png");
  20.      
  21.       //Timer start time
  22.       savedTime = millis();
  23.  
  24.     }
  25.  
  26.   void draw() {
  27.     background(173,236,91);
  28.     basePanda();
  29.     // Calculates how much time has passed
  30.     int passedTime = millis() - savedTime;
  31.     if (passedTime > totalTime) { //If the amount of time that has passed is now greater than the time defined increment the grump
  32.         grump = grump + 1;        //If statement true means increment the grump
  33.         savedTime = millis();     // Save the current time to restart the timer!
  34.     }
  35.    
  36.     if(grump >= 75){ //very sad panda
  37.       vsadPanda();
  38.    
  39.     }else if (grump < 75 && grump > 50 ) { // sad panda
  40.       sadPanda();
  41.    
  42.     }else if (grump < 50 && grump >= 25){ //Normal panda
  43.       normalPanda();
  44.    
  45.     }else if (grump < 25 && grump > 0) { //Happy
  46.       happyPanda();
  47.    
  48.     }else if (grump <= 0){ //Very happy
  49.       vhappyPanda();
  50.  
  51.     }
  52.      
  53.      boundary1();
  54.  
  55.      println("Mouse X: " + mouseX + "| Mouse Y: " + mouseY);
  56.      
  57.   }
  58.     void boundary1(){
  59.        if(mouseX > 150 && mouseX < 349  && mouseY > 144 && mouseY < 353){
  60.          if(happiness == false) {
  61.            grump = grump - 3;
  62.            println("grump; " + grump);
  63.          }
  64.        }
  65.          else {happiness = false;
  66.        }
  67.   }
  68.  
  69.   void vhappyPanda() {
  70.      vhappyPanda = createShape(GROUP);
  71.      
  72.       //Eyes
  73.       lEye = createShape(ELLIPSE, 150, 200, 80, 80);
  74.       rEye = createShape(ELLIPSE, 270, 200, 80, 80);
  75.       tlEye = createShape(ELLIPSE, 150, 230, 70, 70);
  76.       trEye = createShape(ELLIPSE, 280, 230, 70, 70);
  77.       lEye.setFill(color(0));
  78.       rEye.setFill(color(0));
  79.      
  80.       //Nose
  81.       Nose = createShape(ELLIPSE, 235, 285, 30, 15);
  82.       Nose.setFill(color(0));
  83.  
  84.       //Cheeks
  85.       lCheek = createShape(ELLIPSE, 150, 290, 30, 30);
  86.       rCheek = createShape(ELLIPSE, 320, 290, 30, 30);
  87.       lCheek.setFill(color(239,138,244));
  88.       rCheek.setFill(color(239,138,244));
  89.      
  90.       //Smile
  91.       image(smile, -3, 0);
  92.       image(hearts, -3, 0);
  93.      
  94.       vhappyPanda.addChild(lEye);
  95.       vhappyPanda.addChild(rEye);
  96.       vhappyPanda.addChild(tlEye);
  97.       vhappyPanda.addChild(trEye);
  98.       vhappyPanda.addChild(Nose);
  99.       vhappyPanda.addChild(lCheek);
  100.       vhappyPanda.addChild(rCheek);
  101.      
  102.       shape(vhappyPanda);
  103.   }
  104.   void happyPanda() {
  105.      happyPanda = createShape(GROUP);
  106.      
  107.       //Eyes
  108.       lEye = createShape(ELLIPSE, 150, 200, 80, 80);
  109.       rEye = createShape(ELLIPSE, 270, 200, 80, 80);
  110.       lEye.setFill(color(0));
  111.       rEye.setFill(color(0));
  112.  
  113.       //Pupils
  114.       lPupil = createShape(ELLIPSE, 180, 210, 20, 20);
  115.       rPupil = createShape(ELLIPSE, 300, 210, 20, 20);
  116.       lPupil.setFill(color(255));
  117.       rPupil.setFill(color(255));
  118.  
  119.       //Nose
  120.       Nose = createShape(ELLIPSE, 235, 285, 30, 15);
  121.       Nose.setFill(color(0));
  122.  
  123.       //Cheeks
  124.       lCheek = createShape(ELLIPSE, 150, 290, 30, 30);
  125.       rCheek = createShape(ELLIPSE, 320, 290, 30, 30);
  126.       lCheek.setFill(color(239,138,244));
  127.       rCheek.setFill(color(239,138,244));
  128.      
  129.       //Smile
  130.       image(smile, -3, 0);
  131.  
  132.       happyPanda.addChild(lEye);
  133.       happyPanda.addChild(rEye);
  134.       happyPanda.addChild(lPupil);
  135.       happyPanda.addChild(rPupil);
  136.       happyPanda.addChild(Nose);
  137.       happyPanda.addChild(lCheek);
  138.       happyPanda.addChild(rCheek);
  139.  
  140.       shape(happyPanda);
  141.   }
  142.  
  143.   void normalPanda() {
  144.      normalPanda = createShape(GROUP);
  145.      
  146.       //Eyes
  147.       lEye = createShape(ELLIPSE, 150, 200, 80, 80);
  148.       rEye = createShape(ELLIPSE, 270, 200, 80, 80);
  149.       lEye.setFill(color(0));
  150.       rEye.setFill(color(0));
  151.  
  152.       //Pupils
  153.       lPupil = createShape(ELLIPSE, 180, 210, 20, 20);
  154.       rPupil = createShape(ELLIPSE, 300, 210, 20, 20);
  155.       lPupil.setFill(color(255));
  156.       rPupil.setFill(color(255));
  157.  
  158.       //Nose
  159.       Nose = createShape(ELLIPSE, 235, 285, 30, 15);
  160.       Nose.setFill(color(0));
  161.  
  162.       normalPanda.addChild(lEye);
  163.       normalPanda.addChild(rEye);
  164.       normalPanda.addChild(lPupil);
  165.       normalPanda.addChild(rPupil);
  166.       normalPanda.addChild(Nose);
  167.  
  168.       shape(normalPanda);
  169.    }
  170.  
  171.   void sadPanda() {
  172.       sadPanda = createShape(GROUP);
  173.      
  174.       //Eyebrows
  175.       Eyebrow = createShape(RECT, 120, 200, 260, 20);
  176.       Eyebrow.setFill(color(0));
  177.      
  178.       //Eyes
  179.       lEye = createShape(ELLIPSE, 150, 200, 80, 80);
  180.       rEye = createShape(ELLIPSE, 270, 200, 80, 80);
  181.       lEye.setFill(color(0));
  182.       rEye.setFill(color(0));
  183.  
  184.       //Pupils
  185.       lPupil = createShape(ELLIPSE, 190, 250, 20, 20);
  186.       rPupil = createShape(ELLIPSE, 310, 250, 20, 20);
  187.       lPupil.setFill(color(255));
  188.       rPupil.setFill(color(255));
  189.  
  190.       //Nose
  191.       Nose = createShape(ELLIPSE, 235, 285, 30, 15);
  192.       Nose.setFill(color(0));
  193.  
  194.       sadPanda.addChild(lEye);
  195.       sadPanda.addChild(rEye);
  196.       sadPanda.addChild(lPupil);
  197.       sadPanda.addChild(rPupil);
  198.       sadPanda.addChild(Nose);
  199.       sadPanda.addChild(Eyebrow);
  200.  
  201.       shape(sadPanda);
  202.    }
  203.  
  204.   void vsadPanda() {
  205.      vsadPanda = createShape(GROUP);
  206.      
  207.       //Eyes-Mouth-Detail
  208.       image(squint, -3, 0);
  209.      
  210.       //Nose
  211.       Nose = createShape(ELLIPSE, 235, 285, 30, 15);
  212.       Nose.setFill(color(0));
  213.      
  214.       vsadPanda.addChild(Nose);
  215.      
  216.       shape(vsadPanda);
  217.    }
  218.    
  219.   void basePanda() {
  220.      basePanda = createShape(GROUP);
  221.      
  222.       //Ears
  223.       lEar = createShape(ELLIPSE, 65, 90, 100, 100);
  224.       rEar = createShape(ELLIPSE, 335, 90, 100, 100);
  225.       lEar.setFill(color(0));
  226.       rEar.setFill(color(0));
  227.  
  228.       //Face
  229.       Face = createShape(ELLIPSE, 100, 100, 300, 300);
  230.       Face.setFill(color(255));
  231.  
  232.       basePanda.addChild(lEar);
  233.       basePanda.addChild(rEar);
  234.       basePanda.addChild(Face);
  235.  
  236.       shape(basePanda);
  237. }
  238.  
  239. //Event on mouse over to increase happiness
  240. //Ears wiggle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement