//Jack-O-Latern Creator By Emily Baik// //It's Halloween! Create your own Jack-O-Latern using the buttons below!// //Code referenced from Monster Maker Interactive Toy by Peter Francis //Instructions// //CLick on one of the three buttons on the bar bellow to create a Jack-O-Latern// //Button #1: Changes Faces //Button #2: Changes Stems //Button #3: Randomizer // VARIABLES FOR PUMPKIN DESIGN // int pumpkinFace=0; int pumpkinStem=0; float pumpkinColourR=242; float pumpkinColourG=116; float pumpkinColourB=5; //BACKGROUND VARIABLE// int hillsize=400; void setup(){ size(400,400); frameRate(20); //animation of Moon/Stars } void draw(){ background(68,53,96); //Game Background Functions// drawbgGraveyard(); drawfgGraveyard(); drawFence(); drawMoon(); drawDesignBar(); //Pumpkin Design Functions// drawpumpkin(); drawpumpkinFace(); drawpumpkinStem(); } void drawbgGraveyard(){ //Background Hill// noStroke(); fill(55,45,77); rect(0,160,hillsize,hillsize); //Background Tombstones WORK// fill(21,17,30); noStroke(); //BG Tombstone 1// ellipse(160,170,20,25); rect(150,170,20,20); //BG Tombstone 2// ellipse(62,147,15,20); rect(55,147,15,15); //BG Tombstone 3// ellipse(260,190,20,25); rect(250,190,20,20); //BG Tombstone 4// ellipse(358,160,17,23); rect(350,160,17,18); //BG Tombstone 5// ellipse(390,205,20,25); rect(380,205,20,20); } void drawFence(){ //Background Fence WORK //Repeated in order to get equal spacing b/w fence posts for(int i=0; i<400;i+=10){ stroke(0); strokeWeight(1.5); line(i,135,i,159); } strokeWeight(1); rect(0,141,400,1); } void drawMoon(){ //Moon WORK noStroke(); fill(255,255,255); ellipse(320,50,60,60); //Eclipse Effect fill(68,53,96); ellipse(335,43,45,45); //Moon Glow fill(211,243,255,70); ellipse(318,50,75,75); fill(211,243,255,50); ellipse(318,50,sin(frameCount/24.5)*90, sin(frameCount/24.5)*90); //Stars fill(252,245,209); ellipse(242,33,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); ellipse(369,15,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); ellipse(364,90,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); ellipse(185,86,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); ellipse(253,119,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); ellipse(115,18,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); ellipse(73,106,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); ellipse(27,51,sin(frameCount/14.5)*3, sin(frameCount/14.5)*3); } void drawfgGraveyard(){ //Foreground Hill// noStroke(); fill(45,37,63); rect(0,230,hillsize,hillsize); //Foreground Tombstone(s) WORK// fill(21,17,30); //FG Tombstone 1// ellipse(335,240,70,75); rect(300,240,70,70); rect(330,176,5,40); rect(320,185,25,5); //FG Tombstone 2// ellipse(70,210,70,75); rect(35,210,70,70); } void drawDesignBar(){ //Design Bar WORK noStroke(); //Main Bar Border fill(252,168,41); rect(50,350,300,40,10); //Main Bar Colour fill(253,204,130); rect(60,355,280,30,5); //Option Buttons fill(251,174,89); noStroke(); for(int i=145; i<250;i+=40){ noStroke(); rect(i,360,20,20); } } void drawpumpkin(){ //Pumpkin WORK noStroke(); fill(pumpkinColourR,pumpkinColourG,pumpkinColourB); //Main Pumpkin Body ellipse(185, 290, 120, 95); ellipse(215, 290, 120, 95); } //FACE OPTIONS// void drawpumpkinFace(){ //Pumpkin Face WORK fill(84,19,0); if (pumpkinFace==0){ triangle(166,268,155,281,177,281); triangle(233,268,222,281,244,281); ellipse(200,310,80,30); //Cover: meant to overlap and help create a more specific shape fill(242, 116, 5); ellipse(200,298,85,25); triangle(174,305,180,317,190,304); triangle(210,305,220,317,225,304); } else if (pumpkinFace==1) { fill(84,19,0); ellipse(173,270,25,25); ellipse(220,270,25,25); triangle(180,297,210,297,196,315); //Cover fill(pumpkinColourR,pumpkinColourG,pumpkinColourB); ellipse(225,265,15,15); ellipse(177,265,15,15); } else if (pumpkinFace==2){ triangle(195,276,160,255,160,280); triangle(205,276,240,255,240,280); rect(165,300,70,20); //Cover fill(pumpkinColourR,pumpkinColourG,pumpkinColourB); triangle(165,300,175,310,180,300); triangle(220,300,225,310,235,300); } else if (pumpkinFace==3){ ellipse(170,270,50,30); ellipse(230,270,50,30); //Cover fill(pumpkinColourR,pumpkinColourG,pumpkinColourB); ellipse(230,273,50,30); ellipse(170,273,50,30); //Pupils fill(84,19,0); ellipse(187,268,15,15); ellipse(247,268,15,15); //Nose stroke(84,19,0); strokeWeight(2); line(197,273,197,291); noStroke(); ellipse(196,297,15,12); fill(pumpkinColourR,pumpkinColourG,pumpkinColourB); ellipse(199,297,15,12); //Mouth fill(84,19,0); ellipse(200,315,60,20); fill(pumpkinColourR,pumpkinColourG,pumpkinColourB); ellipse(200,312,63,20); } else if (pumpkinFace==4){ ellipse(170,268,50,20); ellipse(225,268,50,20); ellipse(200,310,75,20); //Cover fill(pumpkinColourR,pumpkinColourG,pumpkinColourB); rect(169,258,8,20); rect(220,258,8,20); } } //STEM OPTIONS/// void drawpumpkinStem(){ fill(96,63,18); if (pumpkinStem==0){ triangle(199,243,203,228,193,227); } else if (pumpkinStem==1) { triangle(199,243,185,215,203,215); } else if (pumpkinStem==2){ triangle(199,243,210,215,223,215); } else if (pumpkinStem==3){ triangle(199,243,185,215,200,225); } } //BUTTONS// void mousePressed(){ // DESIGN OPTIONS // if(mouseX>146 && mouseX<163 && mouseY>360 && mouseY<380){ pumpkinFace+=1; if(pumpkinFace==5){ pumpkinFace=0; } } if(mouseX>185 && mouseX<204 && mouseY>360 && mouseY<380){ pumpkinStem+=1; if(pumpkinStem==4){ pumpkinStem=0; } } // RANDOM FUNCTION/// if(mouseX>227 && mouseX<244 && mouseY>360 && mouseY<380){ pumpkinFace=int(random(0,5)); } if(mouseX>227 && mouseX<244 && mouseY>360 && mouseY<380){ pumpkinStem=int(random(0,3)); } }