// Midterm Spring 2013 // Creator: Bianca Bono // creates narrative story of your adventures when encountering a gypsy tent String currentPage; //FIRST PAGE PImage one; PImage cat; //movement of cat on 1st page float catX= 800; float catY= 100; //SECOND PAGE PImage bookshelf; PImage roach; PImage roach2; PImage table; PImage ball; PImage candles; PImage web; PImage potion; //value for potions int value = 255; //starting point of movement for roach float roachX = 370; float roachY = 500; float roach2X = 670; float roach2Y = 400; //move tool for spider float spriteY; float spriteMoveY; //shrunken head eyes float lpupilX; float lpupilY; float rpupilX; float rpupilY; //THIRD PAGE float guyX; PImage bigball; PImage three; PImage guy; //FOURTH PAGE PImage four; PImage gypsy; PImage broken; void setup() { size(850, 600); currentPage = "firstPage"; //FIRST one= loadImage("1.png"); cat= loadImage("cat.png"); //SECOND bookshelf=loadImage("bookshelf.png"); roach= loadImage("roach.png"); roach2= loadImage("roach2.png"); table= loadImage("table.png"); ball= loadImage("ball.png"); candles= loadImage("candles.png"); web= loadImage("web.png"); potion= loadImage("potion.png"); //THIRD three= loadImage("3.png"); bigball= loadImage("bigball.png"); guy= loadImage("guy.png"); spriteY=200; spriteMoveY=7; //FOURTH four= loadImage("4.png"); gypsy= loadImage("gypsy.png"); broken= loadImage("broken.png"); } ///////////////////////////////////////////////// // EVENT ROUTERS void draw() { if (currentPage == "firstPage") { drawFirstPage(); } else if (currentPage == "gypsyRoom") { drawGypsyRoom(); } else if (currentPage == "crystalBall") { drawCrystalBall(); } else if (currentPage == "fourthPage") { drawFourthPage(); } } void mouseReleased() { if (currentPage == "firstPage") { mouseReleasedFirstPage(); } else if (currentPage == "gypsyRoom") { mouseReleasedGypsyRoom(); } else if (currentPage == "crystalBall") { mouseReleasedCrystalBall(); } else if (currentPage == "fourthPage") { mouseReleasedFourthPage(); } } ///////////////////////////////////////////////// // FIRST PAGE void drawFirstPage() { catX = catX -.20; noTint(); image(one, 0, -20); image(cat, catX, 400); textSize (25); fill(0, 0, 0); text("ENTER IF YOU DARE", 590, 100); } void mouseReleasedFirstPage() { if (mouseInRect(320, 200, 150, 200)) { currentPage = "gypsyRoom"; } } ///////////////////////////////////////////////// // SECOND PAGE void drawGypsyRoom() { background(190, 120, 222); noStroke(); fill(158, 125, 173); quad(0, 375, 850, 375, 850, 650, 0, 650 ); fill(217, 178, 235); quad(0, 110, 170, 110, 170, 375, 0, 460); quad(480, 110, 850, 110, 850, 570, 480, 375); noTint(); image(bookshelf, 170, 100); image(roach, roachX, roachY); image(roach2, roach2X, roach2Y); image(table, 20, 350); image(ball, 100, 260); image(candles, 500, 230); image(web, 680, 100); tint(value); image(potion, 360, 127); //candlelight fill(random(242, 255), random(157, 255), 0); ellipse(513, 225, 5, 10); fill(random(242, 255), random(157, 255), 0); ellipse(540, 230, 5, 10); fill(random(242, 255), random(157, 255), 0); ellipse(563, 220, 5, 10); fill(random(242, 255), random(157, 255), 0); ellipse(583, 305, 7, 15); //shrunken head eyes lpupilX=map(mouseX, 0, 950, 200, 210); lpupilY=map(mouseY, 0, 700, 160, 170); rpupilX=map(mouseX, 0, 950, 215, 220); rpupilY=map(mouseY, 0, 700, 160, 170); //left head fill(255); ellipse(205, 160, 10, 10); ellipse(215, 160, 10, 10); fill(0); ellipse(lpupilX, lpupilY, 2, 2); ellipse(rpupilX, rpupilY, 2, 2); //spider moving spriteY=spriteY+spriteMoveY; if (spriteY >= 200) { spriteMoveY = -1; } if (spriteY <= 60) { spriteMoveY = 1; } spriteY = spriteY + spriteMoveY; //draw moving web and spider fill(0); rect(750, 125, 1, spriteY); ellipse(750, spriteY+120, 10, 10); rect(740, spriteY+117, 20, 1); rect(740, spriteY+120, 20, 1); rect(740, spriteY+123, 20, 1); //rate of movement of roach roachX = roachX + .25; roach2X = roach2X - .35; } //value of potions void mouseMoved() { value = value +5; if (value > 255) { value = 0; } } void mouseReleasedGypsyRoom() { if (mouseInRect(100, 260, 120, 100)) { currentPage = "crystalBall"; } } ///////////////////////////////////////////////// // THIRD PAGE void drawCrystalBall() { noTint(); image(three, 0, 0); image(bigball, 255, 72); image(guy, guyX, 200); guyX=map(mouseX, 0, 850, 500, 280); } void mouseReleasedCrystalBall() { if (mouseInRect(270, 80, 400, 400)) { currentPage = "fourthPage"; } } ///////////////////////////////////////////////// // FOURTH PAGE void drawFourthPage() { //images tint(random(0, 255), random(0, 255), random(0, 255)); image(four, 0, 20); image(gypsy, 100, 200); image(broken, 500, 400); //text textSize (25); fill(0, 0, 0); text("YOU BROKE MY", 480, 200); text("CRYSTAL BALL!!!", 480, 220); } void mouseReleasedFourthPage() { if (mouseInRect(120, 0, 600, 600)) { currentPage = "firstPage"; } } ///////////////////////////////////////////////// // UTILITY boolean mouseInRect(float _x, float _y, float _w, float _h) { if (mouseX > _x && mouseY > _y && mouseX < _x +_w && mouseY < _y + _h) { return true; } return false; }