var scene; var MainMenuScene, CatScene, HairScene, HelpScene, FunnyScene, ChefScene, AmazingScene; var orangeColor = color(201, 103, 32); var blueColor = color(139, 174, 199); /** * sets/resets scene to be the sceneObject * * resets coloring, text, angle, framerate, and transformation changes * doesn't reset changes to random or noise * */ var setScene = function(sceneObject) { // reset colors colorMode(RGB, 255); background(255, 255, 255); fill(255, 255, 255); stroke(0, 0, 0); strokeWeight(1); // reset text textFont(createFont("sans-serif"), 12); textAlign(LEFT, BOTTOM); // reset angle mode angleMode = "degrees"; // reset framerate and transformation frameRate(30); resetMatrix(); // reset to loop mode loop(); // set the scene to be one of sceneObject scene = new sceneObject(); }; MainMenuScene = function() { // just like in a normal program, the below lines are called as soon as you make the scene a // MainMenuScene noStroke(); textAlign(CENTER); textFont(createFont("Tahoma"), 48); this.draw = function() { //background Part background(240, 0, 0); // triangle noStroke(); fill(255, 255, 255); translate(220, 260); rotate(sin(frameCount*50)*2); scale(2); triangle(-50, -50, 50, 0, -50, 50); resetMatrix(); filter(BLUR); // hearts fill(255, 181, 181); textSize(72); text("♥ ♥",200,90); // "happy birthday papa" textSize(28); textAlign(CENTER); fill(255, 255, 255); text("Happy Birthday, Papa!",200,78); // subtext textSize(18); text("Click the button to find out\nsix things we love you for", 200, 110); }; this.mouseClicked = function() { setScene(CatScene); }; }; CatScene = function() { noStroke(); textAlign(CENTER); textFont(createFont("Tahoma"), 48); this.draw = function() { background(138, 138, 138); // triangle noStroke(); fill(255, 255, 255); translate(220, 340); rotate(sin(frameCount*50)*2); scale(0.8); triangle(-50, -50, 50, 0, -50, 50); resetMatrix(); filter(BLUR); fill(255, 255, 255); text("Your love of cats", width/2, height/8); fill(0, 0, 0); // mandy ellipse(80, 200, 90, 80); // black back fill(255, 255, 255); ellipse(80, 220, 45, 40); // white bottom fill(161, 98, 44); ellipse(70, 190, 20, 20); // tan forehead triangle(75, 210, 85, 210, 80, 215); // tan nose fill(90, 156, 70); ellipse(65, 200, 20, 15); // left eye green ellipse(95, 200, 20, 15); // right eye green fill(0, 0, 0); ellipse(65, 198, 10, 8); // left eye black ellipse(95, 198, 10, 8); // right eye black fill(222, 145, 145); stroke(196, 122, 61); triangle(50, 190, 35, 160, 60, 180); // left ear triangle(110, 190, 125, 160, 100, 180); // right ear noStroke(); translate(120, 0); fill(255, 255, 255); // candy ellipse(80, 200, 90, 80); // black back fill(255, 255, 255); ellipse(80, 220, 45, 40); // white bottom fill(161, 98, 44); triangle(75, 210, 85, 210, 80, 215); // tan nose fill(90, 156, 70); ellipse(65, 200, 20, 15); // left eye green ellipse(95, 200, 20, 15); // right eye green fill(0, 0, 0); ellipse(65, 198, 10, 8); // left eye black ellipse(95, 198, 10, 8); // right eye black fill(222, 145, 145); stroke(255, 255, 255); triangle(50, 190, 35, 160, 60, 180); // left ear triangle(110, 190, 125, 160, 100, 180); // right ear noStroke(); translate(120, 24); scale(0.9); fill(82, 58, 6); // sandy ellipse(320, 200, 80, 70); ellipse(80, 200, 90, 80); // black back fill(255, 255, 255); ellipse(80, 220, 45, 40); // white bottom fill(161, 98, 44); ellipse(70, 190, 20, 20); // tan forehead triangle(75, 210, 85, 210, 80, 215); // tan nose fill(90, 156, 70); ellipse(65, 200, 20, 15); // left eye green ellipse(95, 200, 20, 15); // right eye green fill(0, 0, 0); ellipse(65, 198, 10, 8); // left eye black ellipse(95, 198, 10, 8); // right eye black fill(222, 145, 145); stroke(69, 36, 9); triangle(50, 190, 35, 160, 60, 180); // left ear triangle(110, 190, 125, 160, 100, 180); // right ear noStroke(); resetMatrix(); }; this.mouseClicked = function() { setScene(HairScene); }; }; HairScene = function() { noStroke(); textAlign(CENTER); textFont(createFont("Tahoma"), 48); var startFrame = frameCount; this.draw = function() { background(34, 68, 189); // triangle noStroke(); fill(255, 255, 255); translate(220, 340); rotate(sin(frameCount*50)*2); scale(0.8); triangle(-50, -50, 50, 0, -50, 50); resetMatrix(); filter(BLUR); fill(255, 255, 255); text("Your great hair", width/2, height/8); translate(200, 180); fill(222, 172, 133); ellipse(0, 0, 100, 100); // papa head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile if(startFrame - frameCount + 255 < 200 && startFrame - frameCount + 255 > 128) { bezier(-20, 20, -10, 10, 10, 10, 20, 20); // smile } noStroke(); fill(61, 39, 20, startFrame - frameCount + 255); arc(0, -18, 100, 64, 180, 360); // hair resetMatrix(); }; this.mouseClicked = function() { setScene(HelpScene); }; }; HelpScene = function() { noStroke(); textAlign(CENTER); textFont(createFont("Tahoma"), 48); background(0, 71, 14); this.draw = function() { fill(0, 71, 14, 100); rect(0, 0, 400, 400); if(random(0, 1) < 0.1) { var img = getImage("cute/Heart"); image(img, random(0, width), random(0, height)); } // triangle noStroke(); fill(255, 255, 255); translate(220, 340); rotate(sin(frameCount*50)*2); scale(0.8); triangle(-50, -50, 50, 0, -50, 50); resetMatrix(); filter(BLUR); translate(200, 180); scale(0.8); fill(102, 68, 48); arc(0, 55, 120, 260, 180, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // mama head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile noStroke(); translate(-150, 0); fill(201, 143, 50); arc(0, 55, 120, 260, 180, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // claire head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile noStroke(); translate(300, 0); fill(79, 51, 10); arc(0, -10, 100, 120, 0, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // raf head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile noStroke(); resetMatrix(); fill(255, 255, 255); text("Your helpfulness", width/2, height/8); }; this.mouseClicked = function() { setScene(FunnyScene); }; }; FunnyScene = function() { noStroke(); textAlign(CENTER); textFont(createFont("Tahoma"), 42); this.draw = function() { background(128, 68, 19); // triangle noStroke(); fill(255, 255, 255); translate(220, 340); rotate(sin(frameCount*50)*2); scale(0.8); triangle(-50, -50, 50, 0, -50, 50); resetMatrix(); filter(BLUR); translate(200, 120); fill(222, 172, 133); ellipse(0, 0, 100, 100); // papa head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile bezier(-20, 20, -10, 10*sin(frameCount*5)+10, 10, 10*sin(frameCount*5)+10, 20, 20); // smile noStroke(); resetMatrix(); translate(200, 250); scale(0.8); fill(102, 68, 48); arc(0, 55, 120, 260, 180, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // mama head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile bezier(-20, 20, -10, 45 + cos(frameCount*30)*5, 10, 45 + cos(frameCount*30)*5, 20, 20); // smile noStroke(); translate(-150, 0); fill(201, 143, 50); arc(0, 55, 120, 260, 180, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // claire head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile bezier(-20, 20, -10, 45 + cos(frameCount*30+90)*5, 10, 45 + cos(frameCount*30+90)*5, 20, 20); // smile noStroke(); translate(300, 0); fill(79, 51, 10); arc(0, -10, 100, 120, 0, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // raf head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile bezier(-20, 20, -10, 45 + sin(frameCount*30+90)*5, 10, 45 + sin(frameCount*30+90)*5, 20, 20); // smile noStroke(); resetMatrix(); fill(255, 255, 255); text("How funny you are", width/2, height/8); }; this.mouseClicked = function() { setScene(ChefScene); }; }; ChefScene = function() { noStroke(); textAlign(CENTER); textFont(createFont("Tahoma"), 48); background(84, 28, 84); this.draw = function() { fill(84, 28, 84, 10); rect(0, 0, 400, 400); // triangle noStroke(); fill(255, 255, 255); translate(220, 340); rotate(sin(frameCount*50)*2); scale(0.8); triangle(-50, -50, 50, 0, -50, 50); resetMatrix(); // filter(BLUR); var imgs = [getImage("avatars/leaf-blue"), getImage("avatars/leaf-green"), getImage("avatars/leaf-grey"), getImage("avatars/leaf-orange"), getImage("avatars/leaf-red"), getImage("avatars/leaf-yellow")]; translate(random(0, width), random(0, height)); rotate(random(-180, 180)); image(imgs[floor(random(0, imgs.length))], 0, 0); resetMatrix(); fill(255, 255, 255); text("Your culinary skills", width/2, height/8); }; this.mouseClicked = function() { setScene(AmazingScene); }; }; AmazingScene = function() { noStroke(); textAlign(CENTER); textFont(createFont("Tahoma"), 48); background(99, 6, 26); this.draw = function() { fill(99, 6, 26); rect(0, 0, 400, 400); var imgs = [getImage("space/star"), getImage("space/healthheart"), getImage("cute/Star"), getImage("creatures/Hopper-Cool")]; translate(random(0, width), random(0, height)); rotate(random(-180, 180)); image(imgs[floor(random(0, imgs.length))], 0, 0); resetMatrix(); translate(200, 180); fill(222, 172, 133); ellipse(0, 0, 100, 100); // papa head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(mouseY-180, mouseX-200)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile noStroke(); resetMatrix(); translate(200, 320); scale(0.8); fill(102, 68, 48); arc(0, 55, 120, 260, 180, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // mama head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile noStroke(); translate(-150, 0); fill(201, 143, 50); arc(0, 55, 120, 260, 180, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // claire head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile noStroke(); translate(300, 0); fill(79, 51, 10); arc(0, -10, 100, 120, 0, 360); // hair fill(222, 172, 133); ellipse(0, 0, 100, 100); // raf head fill(255, 255, 255); ellipse(-20, 0, 10, 10); // left eye white ellipse(20, 0, 10, 10); // right eye white fill(0, 0, 0); pushMatrix(); translate(-20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // left eye white popMatrix(); pushMatrix(); translate(20, 0); rotate(atan2(-1, 0)); translate(5, 0); ellipse(0, 0, 5, 5); // right eye white popMatrix(); stroke(0, 0, 0); fill(0, 0, 0, 0); bezier(-20, 20, -10, 30, 10, 30, 20, 20); // smile noStroke(); resetMatrix(); fill(255, 255, 255); text("How overall\namazing you are!", width/2, height/8); }; this.mouseClicked = function() { Program.restart(); }; }; /** set the inital scene to MainMenuScene **/ setScene(MainMenuScene); /** draw function just calls the scene's draw function **/ draw = function() { scene.draw(); }; /** Mouse and keyboard interactions will call the scene's respective mouse/keyboard function **/ var mouseClicked = function(){ scene.mouseClicked(); }; var mousePressed = function(){ scene.mousePressed(); }; var mouseReleased = function(){ scene.mouseReleased(); }; var mouseMoved = function(){ scene.mouseMoved(); }; var mouseDragged = function(){ scene.mouseDragged(); }; var mouseOver = function(){ scene.mouseOver(); }; var mouseOut = function(){ scene.mouseOut(); }; var keyPressed = function(){ scene.keyPressed(); }; var keyReleased = function(){ scene.keyReleased(); }; var keyTyped = function(){ scene.keyTyped(); }; var keyPressed = function(){ scene.keyPressed(); };