// Fuzzy Adventure - Liliana Nairn // It is a mini puzzle. You have to flip the switch then get to the baby Fuzzy. // Reference - Burglar Escape (2014), reference used for getting the Fuzzy's movements to work. // Variables // The variables used for WASD int moveUp = 0; int moveDown = 0; int moveLeft = 0; int moveRight = 0; float fuzzySpeed = 1.5; // The Y coordinate of the lever int leverTipY1 = 225; int leverTipY2 = 230; int leverY1 = 225; int leverY2 = 245; // Lever true or false boolean lever1 = false; // The X coordinate of the Fuzzy float fuzzyPositionX = 40; // The Y coordinate of the Fuzzy float fuzzyPositionY = 367.5; void setup() { size(400, 400); rectMode(CENTER); ellipseMode(CENTER); // Instructions for the player print("Help! The Fuzzy's baby has been trapped. Help the Fuzzy save the baby by flipping the switch by pressing the spacebar. Then move the Fuzzy with the WASD keys and get to the baby."); } void draw() { // Draw the background drawBackground(); // Draw trap drawTrap(); // Draw the Levers drawLever(); // Draw Walls around Lever drawWalls(); // Update the Lever's position updateLever(); // Update the Lever's position updateDoor(); // How fast the moveSpeed(); // Draw Fuzzy drawFuzzy(); // Draw Baby Fuzzy drawBaby(); // When you get the baby Fuzzy babyFuzzySaved(); //Set Cave boundaries caveBoundaries(); } void keyPressed() { moveFuzzy(); } void moveSpeed() { // The full movement of the Fuzzy fuzzyPositionX = fuzzyPositionX + (moveRight-moveLeft)*fuzzySpeed; fuzzyPositionY = fuzzyPositionY + (moveDown-moveUp)*fuzzySpeed; } // Updates the Fuzzy's position void moveFuzzy() { if (keyPressed) { if (key == 'w' || key == 'W') { moveUp = 1; } else if (key == 'a' || key == 'A') { moveLeft = 1; } else if (key == 's' || key == 'S') { moveDown = 1; } else if (key == 'd' || key == 'D') { moveRight = 1; } } } // Key release void keyReleased() { if (key == 'w' || key == 'W') { moveUp = 0; } else if (key == 'a' || key == 'A') { moveLeft = 0; } else if (key == 's' || key == 'S') { moveDown = 0; } else if (key == 'd' || key == 'D') { moveRight = 0; } } // Updates the Door's Lever position void updateLever() { if (keyPressed) { if (key == ' ') { leverY1 = 245; leverY2 = 265; leverTipY1 = 260; leverTipY2 = 265; drawLever(); } } } // Updates the Door's position void updateDoor() { if (keyPressed) { if (key == ' ') { lever1 = true; } } if (lever1) { fill(68, 70, 79); stroke(68, 70, 79); rect(325, 50, 15, 60); stroke(0); } } // When you save the Fuzzy void babyFuzzySaved() { if ((fuzzyPositionX >= 320) && (fuzzyPositionY <= 100) && (lever1 == true)) { fill(64,41, 0); stroke(64, 41, 0); rect(360, 50, 20, 12.5); fill(255); stroke(0); ellipse(355, 47.5, 5, 15); ellipse(365, 47.5, 5, 15); fill(0); stroke(0); ellipse(355, 47.5, 2.5, 7.5); ellipse(365, 47.5, 2.5, 7.5); print("Yeah! You saved the baby Fuzzy!"); } } // Draws the background void drawBackground() { background(68, 70, 79); fill(33, 34, 38); // Cave walls rect(5, 200, 10, 400); rect(395, 200, 10, 400); rect(200, 5, 400, 10); rect(200, 15, 380, 10); rect(235, 395, 330, 10); } // Draws the Trap walls void drawTrap() { fill(33, 34, 38); stroke(0); for (int doorX = 320; doorX < 335; doorX = doorX + 5) { line(doorX, 10, doorX, 80); } rect(355, 85, 70, 10); rect(355, 95, 70, 10); } // Draws the Fuzzy at its starting position void drawFuzzy() { fill(38, 24, 0); stroke(0); rect(fuzzyPositionX-7.5, fuzzyPositionY+17.5, 2.5, 5); rect(fuzzyPositionX+7.5, fuzzyPositionY+17.5, 2.5, 5); fill(64, 41, 0); ellipse(fuzzyPositionX, fuzzyPositionY, 40, 35); fill(255); ellipse(fuzzyPositionX-5, fuzzyPositionY, 7.5, 15); ellipse(fuzzyPositionX+5, fuzzyPositionY, 7.5, 15); fill(0); ellipse(fuzzyPositionX-5, fuzzyPositionY, 3.25, 7.5); ellipse(fuzzyPositionX+5, fuzzyPositionY, 3.25, 7.5); } // Draws the baby Fuzzy void drawBaby() { fill(64, 41, 0); ellipse(360, 47.5, 30, 25); fill(0); line(352.5, 42.5, 360, 47.5); line(352.5, 50, 360, 47.5); line(367.5, 42.5, 360, 47.5); line(367.5, 50, 360, 47.5); } // Draws the Door Lever void drawLever() { //glow float randomR =random(255); float randomG =random(255); float randomB =random(255); fill(randomR, randomG, randomB, 50); noStroke(); ellipse (250, 245, 50, 50); stroke(0); // Base of lever fill(191, 122, 0); rect(250, 245, 20, 30); fill(0); rect(250, 245, 10, 20); // Handle of lever rectMode(CORNERS); fill(163, 170, 191); rect(247.5, leverY1, 252.5, leverY2); fill(255, 162, 0); rect(247.5, leverTipY1, 252.5, leverTipY2); rectMode(CENTER); } // Draw the Walls void drawWalls() { fill(33, 34, 38); stroke(0); rect(215, 240, 10, 60); rect(285, 240, 10, 60); rect(250, 275, 80, 10); rect(250, 285, 80, 10); } // Boundaries for the Fuzzy not go through cave walls, void caveBoundaries() { if (fuzzyPositionX >= width) { fuzzyPositionX = 380; } else if (fuzzyPositionX <= 0) { fuzzyPositionX = 20; } else if (fuzzyPositionY >= height) { fuzzyPositionY = 380; } else if (fuzzyPositionY <= 0) { fuzzyPositionY = 20; } }