Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PShape basePanda, normalPanda, happyPanda, vhappyPanda, sadPanda, vsadPanda, lEar, rEar, Face, lEye, rEye, tlEye, trEye, lPupil, rPupil, lCheek, rCheek, Nose, Eyebrow;
- PImage squint, smile, hearts;
- int savedTime;
- int totalTime = 500;
- int grump = 25;
- boolean happiness = false;
- void setup() {
- size(500, 500, P2D);
- noStroke();
- background(173,236,91);
- ellipseMode(CENTER);
- smooth();
- cursor();
- //Imports png images to display
- squint = loadImage("squint.png");
- smile = loadImage("smile.png");
- hearts = loadImage("hearts.png");
- //Timer start time
- savedTime = millis();
- }
- void draw() {
- background(173,236,91);
- basePanda();
- // Calculates how much time has passed
- int passedTime = millis() - savedTime;
- if (passedTime > totalTime) { //If the amount of time that has passed is now greater than the time defined increment the grump
- grump = grump + 1; //If statement true means increment the grump
- savedTime = millis(); // Save the current time to restart the timer!
- }
- if(grump >= 75){ //very sad panda
- vsadPanda();
- }else if (grump < 75 && grump > 50 ) { // sad panda
- sadPanda();
- }else if (grump < 50 && grump >= 25){ //Normal panda
- normalPanda();
- }else if (grump < 25 && grump > 0) { //Happy
- happyPanda();
- }else if (grump <= 0){ //Very happy
- vhappyPanda();
- }
- boundary1();
- println("Mouse X: " + mouseX + "| Mouse Y: " + mouseY);
- }
- void boundary1(){
- if(mouseX > 150 && mouseX < 349 && mouseY > 144 && mouseY < 353){
- if(happiness == false) {
- grump = grump - 3;
- println("grump; " + grump);
- }
- }
- else {happiness = false;
- }
- }
- void vhappyPanda() {
- vhappyPanda = createShape(GROUP);
- //Eyes
- lEye = createShape(ELLIPSE, 150, 200, 80, 80);
- rEye = createShape(ELLIPSE, 270, 200, 80, 80);
- tlEye = createShape(ELLIPSE, 150, 230, 70, 70);
- trEye = createShape(ELLIPSE, 280, 230, 70, 70);
- lEye.setFill(color(0));
- rEye.setFill(color(0));
- //Nose
- Nose = createShape(ELLIPSE, 235, 285, 30, 15);
- Nose.setFill(color(0));
- //Cheeks
- lCheek = createShape(ELLIPSE, 150, 290, 30, 30);
- rCheek = createShape(ELLIPSE, 320, 290, 30, 30);
- lCheek.setFill(color(239,138,244));
- rCheek.setFill(color(239,138,244));
- //Smile
- image(smile, -3, 0);
- image(hearts, -3, 0);
- vhappyPanda.addChild(lEye);
- vhappyPanda.addChild(rEye);
- vhappyPanda.addChild(tlEye);
- vhappyPanda.addChild(trEye);
- vhappyPanda.addChild(Nose);
- vhappyPanda.addChild(lCheek);
- vhappyPanda.addChild(rCheek);
- shape(vhappyPanda);
- }
- void happyPanda() {
- happyPanda = createShape(GROUP);
- //Eyes
- lEye = createShape(ELLIPSE, 150, 200, 80, 80);
- rEye = createShape(ELLIPSE, 270, 200, 80, 80);
- lEye.setFill(color(0));
- rEye.setFill(color(0));
- //Pupils
- lPupil = createShape(ELLIPSE, 180, 210, 20, 20);
- rPupil = createShape(ELLIPSE, 300, 210, 20, 20);
- lPupil.setFill(color(255));
- rPupil.setFill(color(255));
- //Nose
- Nose = createShape(ELLIPSE, 235, 285, 30, 15);
- Nose.setFill(color(0));
- //Cheeks
- lCheek = createShape(ELLIPSE, 150, 290, 30, 30);
- rCheek = createShape(ELLIPSE, 320, 290, 30, 30);
- lCheek.setFill(color(239,138,244));
- rCheek.setFill(color(239,138,244));
- //Smile
- image(smile, -3, 0);
- happyPanda.addChild(lEye);
- happyPanda.addChild(rEye);
- happyPanda.addChild(lPupil);
- happyPanda.addChild(rPupil);
- happyPanda.addChild(Nose);
- happyPanda.addChild(lCheek);
- happyPanda.addChild(rCheek);
- shape(happyPanda);
- }
- void normalPanda() {
- normalPanda = createShape(GROUP);
- //Eyes
- lEye = createShape(ELLIPSE, 150, 200, 80, 80);
- rEye = createShape(ELLIPSE, 270, 200, 80, 80);
- lEye.setFill(color(0));
- rEye.setFill(color(0));
- //Pupils
- lPupil = createShape(ELLIPSE, 180, 210, 20, 20);
- rPupil = createShape(ELLIPSE, 300, 210, 20, 20);
- lPupil.setFill(color(255));
- rPupil.setFill(color(255));
- //Nose
- Nose = createShape(ELLIPSE, 235, 285, 30, 15);
- Nose.setFill(color(0));
- normalPanda.addChild(lEye);
- normalPanda.addChild(rEye);
- normalPanda.addChild(lPupil);
- normalPanda.addChild(rPupil);
- normalPanda.addChild(Nose);
- shape(normalPanda);
- }
- void sadPanda() {
- sadPanda = createShape(GROUP);
- //Eyebrows
- Eyebrow = createShape(RECT, 120, 200, 260, 20);
- Eyebrow.setFill(color(0));
- //Eyes
- lEye = createShape(ELLIPSE, 150, 200, 80, 80);
- rEye = createShape(ELLIPSE, 270, 200, 80, 80);
- lEye.setFill(color(0));
- rEye.setFill(color(0));
- //Pupils
- lPupil = createShape(ELLIPSE, 190, 250, 20, 20);
- rPupil = createShape(ELLIPSE, 310, 250, 20, 20);
- lPupil.setFill(color(255));
- rPupil.setFill(color(255));
- //Nose
- Nose = createShape(ELLIPSE, 235, 285, 30, 15);
- Nose.setFill(color(0));
- sadPanda.addChild(lEye);
- sadPanda.addChild(rEye);
- sadPanda.addChild(lPupil);
- sadPanda.addChild(rPupil);
- sadPanda.addChild(Nose);
- sadPanda.addChild(Eyebrow);
- shape(sadPanda);
- }
- void vsadPanda() {
- vsadPanda = createShape(GROUP);
- //Eyes-Mouth-Detail
- image(squint, -3, 0);
- //Nose
- Nose = createShape(ELLIPSE, 235, 285, 30, 15);
- Nose.setFill(color(0));
- vsadPanda.addChild(Nose);
- shape(vsadPanda);
- }
- void basePanda() {
- basePanda = createShape(GROUP);
- //Ears
- lEar = createShape(ELLIPSE, 65, 90, 100, 100);
- rEar = createShape(ELLIPSE, 335, 90, 100, 100);
- lEar.setFill(color(0));
- rEar.setFill(color(0));
- //Face
- Face = createShape(ELLIPSE, 100, 100, 300, 300);
- Face.setFill(color(255));
- basePanda.addChild(lEar);
- basePanda.addChild(rEar);
- basePanda.addChild(Face);
- shape(basePanda);
- }
- //Event on mouse over to increase happiness
- //Ears wiggle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement