///////TAMAGOTCHI INTERACTIVE TOY///// ///Gillianne Gignac/// ///Nicolas Hesler/// ///P02/// float scrollSpeed = 1; float triangY1 = 170; float triangY2 = 220; float triangY3 = 230; float barY = 225; float bounce =0; float mouthX = 170; float mouthY = 200; //float hungerBar = 0; float bar1Y = 160; float b; float screenR = 255; float screenG = 188; float screenB = 219; int yPos =1; int count = 0; boolean wait = false; boolean muffin = false; boolean heart = false; boolean glasses = false; boolean Bar1 = false; // button corrdinates float muffinButtonX = 140; float muffinButtonY = 290; float heartButtonX = 190; float heartButtonY = 300; float glassButtonX = 240; float glassButtonY = 290; //button hit box float buttonW = 20; float buttonH = 20; void setup() { size (400, 400); } void draw() { b = random(255); drawBackground(); drawSquares(); drawTamagotchi(); drawScreen(); hungerBar(); drawPet(); //can not press another button while another is in use if (wait) { count ++; } if (count == 45) { wait = false; count = 0; } //HUNGER BAR INCREASES BY AND INCREMENT OF 10 EVERYTIME MOUSE IS PRESSED if (mouseX >= mouthX && mouseY >= mouthY && mouseX <= mouthX+buttonW && mouseY <= mouthY+buttonH && mousePressed && muffin) { muffin = false; Bar1 = false; print("I'm full! "); } else if (mouseX >= mouthX && mouseY >= mouthY && mouseX <= mouthX+buttonW && mouseY <= mouthY+buttonH && mousePressed) { muffin = false; Bar1 = true; } if (Bar1) { drawHunger(); } //MUFFIN BUTTON buttonW = 20; buttonH = 20; if (mouseX >= muffinButtonX && mouseY >= muffinButtonY && mouseX <= muffinButtonX+buttonW && mouseY <= muffinButtonY+buttonH && mousePressed && muffin && !wait) { muffin = false; wait = true; } else if (mouseX >= muffinButtonX && mouseY >= muffinButtonY && mouseX <= muffinButtonX+buttonW && mouseY <= muffinButtonY+buttonH && mousePressed && !wait) { //disable other buttons muffin = true; heart = false; glasses = false; screenR = 255; screenG = 188; screenB = 219; wait =true; } if (muffin) { drawMuffin(); } else if (heart) { } //HEART BUTTON if (mouseX >= heartButtonX && mouseY >= heartButtonY && mouseX <= heartButtonX+buttonW && mouseY <= heartButtonY+buttonH && mousePressed && heart && !wait) { heart = false; wait = true; } else if (mouseX >= heartButtonX && mouseY >= heartButtonY && mouseX <= heartButtonX+buttonW && mouseY <= heartButtonY+buttonH && mousePressed && !wait) { //disable other buttons muffin = false; heart = true; glasses = false; screenR = 255; screenG = 188; screenB = 219; wait =true; } if (heart) { drawHeart(); } //SUNGLASSES BUTTON if (mouseX >= glassButtonX && mouseY >= glassButtonY && mouseX <= glassButtonX+buttonW && mouseY <= glassButtonY+buttonH && mousePressed && glasses && !wait) { glasses = false; wait = true; screenR = 255; screenG = 188; screenB = 219; } else if (mouseX >= glassButtonX && mouseY >= glassButtonY && mouseX <= glassButtonX+buttonW && mouseY <= glassButtonY+buttonH && mousePressed && !wait) { //disable other buttons muffin = false; heart = false; glasses = true; wait =true; print("Wooaahh, craaazy! "); screenR = 255; screenG = 2; screenB = 170; } if (glasses) { drawGlasses(); } } //DRAW BLUE BACKGROUND void drawBackground() { background (217, 229, 247); } //SQUARES IN THE BACKGROUND void drawSquares() { //background squares fill(196, 178, 255); noStroke(); rectMode(CENTER); rect(80, 60, 80, 80); fill(255, 238, 193); noStroke(); rectMode(CENTER); rect(80, 180, 80, 80); fill(255, 181, 181); noStroke(); rectMode(CENTER); rect(80, 300, 80, 80); fill(255, 238, 193); noStroke(); rectMode(CENTER); rect(180, 60, 80, 80); fill(255, 181, 181); noStroke(); rectMode(CENTER); rect(340, 80, 80, 80); fill(196, 178, 255); noStroke(); rectMode(CENTER); rect(340, 340, 80, 80); } //DRAW ACTUAL TOY void drawTamagotchi() { //tamagotchi fill(252, 243, 83); stroke(234, 217, 63); strokeWeight(3); arc(200, 220, 240, 200, 0, PI); fill(252, 243, 83); stroke(234, 217, 63); strokeWeight(3); arc(200, 220, 240, 360, -PI, 0); fill(255, 238, 193); stroke(234, 217, 63); ellipse(200, 60, 20, 20); fill(234, 217, 63); noStroke(); ellipse(200, 300, 20, 20); fill(234, 217, 63); noStroke(); ellipse(250, 290, 20, 20); fill(234, 217, 63); noStroke(); ellipse(150, 290, 20, 20); } //CREATE THE SCREEN ON THE TAMAGOTCHI void drawScreen() { //screen stroke(0); strokeWeight(4); rectMode(CENTER); rect(200, 210, 160, 120); fill(screenR, screenG, screenB); noStroke(); rect(200, 210, 160, 80); // triangles in the background TOP row fill(233, 255, 188); noStroke(); triangle(140, triangY1+20, 120, triangY1, 160, triangY1); fill(233, 255, 188); noStroke(); triangle(180, triangY1+20, 160, triangY1, 200, triangY1); fill(233, 255, 188); noStroke(); triangle(220, triangY1+20, 200, triangY1, 240, triangY1); fill(233, 255, 188); noStroke(); triangle(260, triangY1+20, 240, triangY1, 280, triangY1); // bar between triangles 2 and 3 fill(233, 255, 188); noStroke(); rect(200, barY, 160, 10); // triangles SECOND row fill(233, 255, 188); noStroke(); triangle(120, triangY2-20, 140, triangY2, 120, triangY2); fill(233, 255, 188); noStroke(); triangle(160, triangY2-20, 180, triangY2, 140, triangY2); fill(233, 255, 188); noStroke(); triangle(200, triangY2-20, 220, triangY2, 180, triangY2); fill(233, 255, 188); noStroke(); triangle(240, triangY2-20, 260, triangY2, 220, triangY2); fill(233, 255, 188); noStroke(); triangle(280, triangY2-20, 280, triangY2, 260, triangY2); //THIRD row of triangles fill(233, 255, 188); noStroke(); triangle(140, triangY3+20, 120, triangY3, 160, triangY3); fill(233, 255, 188); noStroke(); triangle(180, triangY3+20, 160, triangY3, 200, triangY3); fill(233, 255, 188); noStroke(); triangle(220, triangY3+20, 200, triangY3, 240, triangY3); fill(233, 255, 188); noStroke(); triangle(260, triangY3+20, 240, triangY3, 280, triangY3); //grey borders fill(174, 186, 182); noStroke(); rectMode(CENTER); rect(200, 160, 160, 20); fill(174, 186, 182); noStroke(); rectMode(CENTER); rect(200, 260, 160, 20); //black border noFill(); stroke(0); strokeWeight(4); rectMode(CENTER); rect(200, 210, 160, 120); // heart "button" fill(0); noStroke(); triangle(200, 266, 195, 259, 205, 259); fill(0); noStroke(); ellipse(197, 258, 5, 5); fill(0); noStroke(); ellipse(203, 258, 5, 5); //muffin stroke(0); arc(150, 260, 8, 8, -PI, 0); noFill(); strokeWeight(1.3); rectMode(CENTER); rect(150, 263, 6, 6); //glasses button noFill(); stroke(0); strokeWeight(1.5); ellipse(255, 260, 5, 5); ellipse(245, 260, 5, 5); line(247.5, 260, 252.5, 260); } //HUNGER BAR void hungerBar () { noFill(); stroke(0); strokeWeight(2); rect(140, 160, 30, 10); stroke(0); arc(165, 160, 8, 8, -PI, 0); noFill(); strokeWeight(1.3); rectMode(CENTER); rect(165, 163, 6, 6); } //CREATE HUNGER METER void drawHunger() { fill(0); noStroke(); rectMode(CENTER); rect(140, 160, 30, 10); } //draw Tamagotchi Pet void drawPet () { //RIGHT LEG fill(0); noStroke(); rect(195, 240, 5, 5); fill(0); noStroke(); rect(200, 235, 5, 5); fill(0); noStroke(); rect(200, 230, 5, 5); fill(0); noStroke(); rect(190, 235, 5, 5); fill(0); noStroke(); rect(190, 230, 5, 5); //LEFT LEG fill(0); noStroke(); rect(215, 240, 5, 5); fill(0); noStroke(); rect(210, 235, 5, 5); fill(0); noStroke(); rect(210, 230, 5, 5); fill(0); noStroke(); rect(220, 235, 5, 5); fill(0); noStroke(); rect(220, 230, 5, 5); //BODY fill(0); noStroke(); rect(205, 230, 5, 5); fill(0); noStroke(); rect(225, 225, 5, 5); fill(0); noStroke(); rect(230, 220, 5, 5); fill(0); noStroke(); rect(230, 215, 5, 5); fill(0); noStroke(); rect(225, 210, 5, 5); fill(0); noStroke(); rect(225, 205, 5, 5); fill(0); noStroke(); rect(225, 200, 5, 5); fill(0); noStroke(); rect(220, 195, 5, 5); fill(0); noStroke(); rect(215, 190, 5, 5); fill(0); noStroke(); rect(210, 185, 5, 5); fill(0); noStroke(); rect(205, 185, 5, 5); fill(0); noStroke(); rect(200, 185, 5, 5); fill(0); noStroke(); rect(195, 185, 5, 5); fill(0); noStroke(); rect(190, 190, 5, 5); fill(0); noStroke(); rect(185, 195, 5, 5); fill(0); noStroke(); rect(180, 195, 5, 5); fill(0); noStroke(); rect(175, 195, 5, 5); fill(0); noStroke(); rect(170, 200, 5, 5); fill(0); noStroke(); rect(175, 205, 5, 5); fill(0); noStroke(); rect(180, 205, 5, 5); fill(0); noStroke(); rect(185, 205, 5, 5); fill(0); noStroke(); rect(170, 210, 5, 5); fill(0); noStroke(); rect(175, 215, 5, 5); fill(0); noStroke(); rect(180, 215, 5, 5); fill(0); noStroke(); rect(185, 215, 5, 5); fill(0); noStroke(); rect(185, 220, 5, 5); fill(0); noStroke(); rect(185, 225, 5, 5); //EYES fill(0); noStroke(); rect(210, 195, 5, 5); fill(0); noStroke(); rect(195, 195, 5, 5); //ARM fill(0); noStroke(); rect(210, 220, 5, 5); fill(0); noStroke(); rect(205, 215, 5, 5); fill(0); noStroke(); rect(215, 215, 5, 5); } void petBounce() { } //DRAW MUFFIN void drawMuffin() { fill(102, 78, 49); noStroke(); rect(mouseX, mouseY+4, 10, 8); fill(255, 233, 183); noStroke(); arc(mouseX, mouseY, 15, 15, -PI, 0); fill(19, 34, 86); noStroke(); rect(mouseX-4, mouseY-2, 1, 1); fill(19, 34, 86); noStroke(); rect(mouseX+4, mouseY-3, 1, 1); fill(19, 34, 86); noStroke(); rect(mouseX, mouseY-4, 1, 1); } //DRAW HEARTS void drawHeart() { fill(193, 34, 71); noStroke(); triangle(200, 182, 195, 175, 205, 175); fill(193, 34, 71); noStroke(); ellipse(197, 175, 5, 5); fill(193, 34, 71); noStroke(); ellipse(203, 175, 5, 5); fill(193, 34, 71); noStroke(); triangle(180, 190, 175, 183, 185, 183); fill(193, 34, 71); noStroke(); ellipse(177, 183, 5, 5); fill(193, 34, 71); noStroke(); ellipse(183, 183, 5, 5); fill(193, 34, 71); noStroke(); triangle(220, 190, 215, 183, 225, 183); fill(193, 34, 71); noStroke(); ellipse(223, 183, 5, 5); fill(193, 34, 71); noStroke(); ellipse(217, 183, 5, 5); } //DRAW SUNGLASSES void drawGlasses() { fill(135, 135, 135); noStroke(); rect(210, 195, 25, 2); fill(114, b, 255); stroke(135, 135, 135); strokeWeight(2); ellipse(205, 195, 10, 10); ellipse(190, 195, 10, 10); }