/*///////////////////////////////////////////////////////////////////////////////////////////////////// Interactive Toy: Tree Growing Simulator Christina Chu A project with aesthetics inspired by the cartoon Steven Universe. A lot of ideas and were scrapped due to me being lazy to program a pseudo point-click-adventure with an animated avatar (mostly because I think it would've been easier if the other chapters from processing were allowed). The background and stuff remained relatively the same and I randomly came up with a new idea of a tree that could match the height of the iconic water pillar from Steven Universe. PRESS BUTTONS AND WATCH YOUR TREE THING GROW!!! *////////////////////////////////////////////////////////////////////////////////////////////////////// //declaring variables float waterEffectLocation; float waterEffectHeight; float waterFallY; float foregroundWavesX = 180; float backgroundWavesX = 500; float waterPlatformForeX = 90; float waterPlatformBackX = 230; int waterPlatformBackTranslate = 0; int currentScene = 0; int keyNumber = 0; int plantStage = 0; int plantType = 0; int randomR; int randomG; int randomB; int waterPlatformForeTranslate = 0; boolean hasChosenPlant = false; void setup() { size (400, 400); fill(65, 87, 155); rect(0, 0, 400, 300); } void draw() { createSceneBackground(); waterEffect(); drawArrow(); } //Changes the required key to be pressed randomly and grows the plant by a single stage. Randomly changes the colour of the plant too. void keyPressed() { if (plantStage < 17 && hasChosenPlant == true) { if (key == 'q' && keyNumber == 0) { plantStage += 1; keyNumber = (int) random(0, 3); generateRandomColours(); } else if (key == 'w' && keyNumber == 1) { plantStage += 1; keyNumber = (int) random(0, 3); generateRandomColours(); } else if (key == 'e' && keyNumber == 2) { plantStage += 1; keyNumber = (int) random(0, 3); generateRandomColours(); } } } //Controls what happens when the mouse is pressed void mousePressed() { //changes the scene if the mouse button is pressed at the top or bottom on the scene if (mouseY <= 49 && currentScene == 0 && hasChosenPlant == true) { currentScene = 1; } else if (mouseY >=350 && currentScene == 1) { currentScene = 0; } else if (mouseY <= 49 && currentScene == 1) { currentScene = 2; } else if (mouseY >=350 && currentScene == 2) { currentScene = 1; } //Some flavor text for whenever the player randomly clicks on the screen for no apparent reason if ((plantStage < 17) && (hasChosenPlant == true) && (mouseY >= 49 && currentScene == 0) && (mouseY <=350 && currentScene == 0)) { println("Wow, press those keyboard buttons you lazy coot!"); }else if ((plantStage < 17) && (hasChosenPlant == true) && (mouseY <=350 && currentScene == 1) && (mouseY >= 49 && currentScene == 1)){ println("Dude, press those buttons."); }else if ((plantStage < 17) && (hasChosenPlant == true) && (mouseY <=350 && currentScene == 2) && (mouseY >= 49 && currentScene == 2)){ println("...Just press them..."); }else if ((plantStage >= 17) && (hasChosenPlant == true) && (mouseY <=350) && (mouseY >= 49)){ println("You sir, deserve a cookie."); } //player can click on "buttons" to determine the type of plant that will grow if (hasChosenPlant == false) { if ((mouseX < 130 && mouseX > 70) && (mouseY > 150 && mouseY < 210)) { hasChosenPlant = true; plantType = 0; } else if ((mouseX > 170 && mouseX < 230) && (mouseY > 150 && mouseY < 210)) { hasChosenPlant = true; plantType = 1; } else if ((mouseX > 270 && mouseX < 330) && (mouseY > 150 && mouseY < 210)) { hasChosenPlant = true; plantType = 2; } } } //Draws the selection of plant seeds the player can choose and click on if the player hasn't already chosen a seed void startPlantChoice() { if (hasChosenPlant == false) { fill(100, 94, 135, 150); rect(0, 0, 400, 400); rectMode(CORNER); stroke(100, 81, 193); strokeWeight(3); //first choice fill(255, 255, 255, 200); rect(70, 150, 60, 60); noStroke(); fill(115, 51, 183); quad(110, 170, 90, 170, 80, 200, 110, 190); fill(188, 226, 255); ellipseMode(CENTER); ellipse(105, 172, 20, 20); //second choice stroke(100, 81, 193); strokeWeight(3); fill(255, 255, 255, 200); rect(170, 150, 60, 60); noStroke(); fill(63, 159, 186); quad(190, 170, 210, 170, 200, 200, 190, 180); fill(114, 255, 231); quad(200, 170, 200, 200, 210, 180, 210, 160); //third choice stroke(100, 81, 193); strokeWeight(3); fill(255, 255, 255, 200); rect(270, 150, 60, 60); noStroke(); fill(98, 107, 239); quad(290, 190, 300, 160, 310, 180, 300, 190); fill(123, 202, 224); quad(300, 180, 300, 190, 320, 190, 310, 180); } } //Generate stars in fixed locations depending on the scene. They should "flicker" with light. void starGeneration() { fill(255, 255, 255, random(30+ plantStage*3, 100 + plantStage*3)); noStroke(); ellipseMode(CENTER); if (currentScene == 0) { ellipse(270, 30, random(2, 4), random (2, 4)); ellipse(200, 50, random(3, 5), random (3, 5)); ellipse(230, 15, random(2, 4), random (2, 4)); } else if (currentScene == 1) { ellipse(330, 20, random(2, 4), random (2, 4)); ellipse(360, 60, random(3, 5), random (3, 5)); ellipse(320, 120, random(6, 8), random (6, 8)); ellipse(260, 60, random(2, 4), random (2, 4)); ellipse(200, 200, random(3, 5), random (3, 5)); ellipse(270, 230, random(2, 4), random (2, 4)); ellipse(210, 330, random(5, 6), random (5, 6)); ellipse(280, 240, random(2, 4), random (2, 4)); ellipse(200, 10, random(2, 4), random (2, 4)); } else if (currentScene == 2) { ellipse(30, 30, random(5, 7), random (5, 7)); ellipse(20, 110, random(3, 5), random (3, 5)); ellipse(90, 120, random(6, 8), random (6, 8)); ellipse(160, 70, random(2, 4), random (2, 4)); ellipse(210, 180, random(3, 5), random (3, 5)); ellipse(330, 220, random(2, 4), random (2, 4)); ellipse(350, 90, random(5, 6), random (5, 6)); ellipse(345, 85, random(2, 4), random (2, 4)); ellipse(320, 290, random(2, 4), random (2, 4)); } } //Shows the actual plant growth on screen and changes depending on the current scene void plantGrowth() { noStroke(); //grows the first type of plant if (plantType == 0) { if (currentScene == 0) { if (plantStage == 1) { fill(167, 102, 193); rectMode(CORNERS); rect(235, 180, 245, 130); } else if (plantStage == 2) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 180, 245, 70); } else if (plantStage == 3) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 180, 245, 40); } else if (plantStage >= 4) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 180, 245, 0); } } else if (currentScene == 1) { if (plantStage == 4) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 390); } else if (plantStage == 5) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 340); } else if (plantStage == 6) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 290); } else if (plantStage == 7) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 240); } else if (plantStage == 8) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 190); } else if (plantStage == 9) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 140); } else if (plantStage == 10) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 80); } else if (plantStage == 11) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 30); } else if (plantStage >= 12) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 0); } } else if (currentScene == 2) { if (plantStage == 12) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 360); } else if (plantStage == 13) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 300); } else if (plantStage == 14) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 250); } else if (plantStage == 15) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 190); rect (320, 200, 245, 190); rect (200, 200, 235, 190); } else if (plantStage == 16) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 190); rect (320, 200, 245, 190); rect (200, 200, 235, 190); rect (320, 200, 330, 130); rect (200, 200, 210, 160); } else if (plantStage >= 17) { fill(randomR, randomG, randomB); rectMode(CORNERS); rect (235, 400, 245, 190); rect (320, 200, 245, 190); rect (200, 200, 235, 190); rect (320, 200, 330, 130); rect (200, 200, 210, 160); fill(255); stroke(255, 255, 255, random(30, 60)); strokeWeight(random(10, 20)); ellipse(325, 80, 100, 100); ellipse(200, 140, 40, 40); ellipse(210, 160, 15, 15); } } //grows the second kind of plant } else if (plantType == 1) { if (currentScene == 0) { if (plantStage == 1) { fill(167, 102, 193); quad(240, 180, 230, 150, 210, 110, 240, 150); } else if (plantStage == 2) { fill(randomR, randomG, randomB); quad(240, 180, 230, 150, 210, 110, 240, 150); quad(240, 160, 255, 120, 240, 80, 240, 120); } else if (plantStage == 3) { fill(randomR, randomG, randomB); quad(240, 180, 230, 150, 210, 110, 240, 150); quad(240, 160, 255, 120, 240, 80, 240, 120); quad(240, 150, 210, 80, 220, 50, 230, 80); } else if (plantStage >= 4) { fill(randomR, randomG, randomB); quad(240, 180, 230, 150, 210, 110, 240, 150); quad(240, 160, 255, 120, 240, 80, 240, 120); quad(240, 150, 210, 80, 220, 50, 230, 80); quad(240, 80, 220, 30, 240, 0, 245, 30); quad(240, 80, 260, 60, 290, 50, 270, 80); } } else if (currentScene == 1) { if (plantStage == 4) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); } else if (plantStage == 5) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); } else if (plantStage == 6) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); quad(243, 370, 240, 325, 260, 250, 220, 340); } else if (plantStage == 7) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); quad(243, 370, 240, 325, 260, 250, 220, 340); quad(245, 340, 245, 320, 280, 190, 280, 160); quad(250, 310, 270, 250, 290, 230, 270, 270); } else if (plantStage == 8) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); quad(243, 370, 240, 325, 260, 250, 220, 340); quad(245, 340, 245, 320, 280, 190, 280, 160); quad(250, 310, 270, 250, 290, 230, 270, 270); quad(270, 240, 280, 230, 260, 105, 260, 200); } else if (plantStage == 9) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); quad(243, 370, 240, 325, 260, 250, 220, 340); quad(245, 340, 245, 320, 280, 190, 280, 160); quad(250, 310, 270, 250, 290, 230, 270, 270); quad(270, 240, 280, 230, 260, 105, 260, 200); quad(275, 165, 305, 120, 280, 60, 270, 125); } else if (plantStage == 10) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); quad(243, 370, 240, 325, 260, 250, 220, 340); quad(245, 340, 245, 320, 280, 190, 280, 160); quad(250, 310, 270, 250, 290, 230, 270, 270); quad(270, 240, 280, 230, 260, 105, 260, 200); quad(275, 165, 305, 120, 280, 60, 270, 125); quad(270, 120, 270, 60, 255, 13, 245, 65); } else if (plantStage == 11) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); quad(243, 370, 240, 325, 260, 250, 220, 340); quad(245, 340, 245, 320, 280, 190, 280, 160); quad(250, 310, 270, 250, 290, 230, 270, 270); quad(270, 240, 280, 230, 260, 105, 260, 200); quad(275, 165, 305, 120, 280, 60, 270, 125); quad(270, 120, 270, 60, 255, 13, 245, 65); quad(265, 230, 250, 180, 210, 150, 240, 205); quad(300, 90, 280, 55, 300, 10, 280, 35); quad(240, 250, 200, 270, 225, 230, 260, 230); } else if (plantStage >= 12) { fill(randomR, randomG, randomB); triangle(245, 370, 235, 400, 255, 400); quad(245, 370, 280, 340, 270, 280, 250, 340); quad(243, 370, 240, 325, 260, 250, 220, 340); quad(245, 340, 245, 320, 280, 190, 280, 160); quad(250, 310, 270, 250, 290, 230, 270, 270); quad(270, 240, 280, 230, 260, 105, 260, 200); quad(275, 165, 305, 120, 280, 60, 270, 125); quad(270, 120, 270, 60, 255, 13, 245, 65); quad(265, 230, 250, 180, 210, 150, 240, 205); quad(300, 90, 280, 55, 300, 10, 280, 35); quad(240, 250, 200, 270, 225, 230, 260, 230); triangle(250, 0, 275, 50, 290, 0); } } else if (currentScene == 2) { if (plantStage == 12) { fill(randomR, randomG, randomB); quad(290, 335, 260, 360, 275, 400, 315, 375); quad(270, 400, 240, 330, 200, 350, 230, 385); } else if (plantStage == 13) { fill(randomR, randomG, randomB); quad(290, 335, 260, 360, 275, 400, 315, 375); quad(270, 400, 240, 330, 200, 350, 230, 385); quad(260, 345, 315, 290, 310, 235, 275, 285); } else if (plantStage == 14) { fill(randomR, randomG, randomB); quad(290, 335, 260, 360, 275, 400, 315, 375); quad(270, 400, 240, 330, 200, 350, 230, 385); quad(260, 345, 315, 290, 310, 235, 275, 285); quad(255, 345, 245, 280, 200, 210, 215, 300); } else if (plantStage == 15) { fill(randomR, randomG, randomB); quad(290, 335, 260, 360, 275, 400, 315, 375); quad(270, 400, 240, 330, 200, 350, 230, 385); quad(260, 345, 315, 290, 310, 235, 275, 285); quad(255, 345, 245, 280, 200, 210, 215, 300); quad(260, 330, 250, 280, 200, 200, 270, 260); } else if (plantStage == 16) { fill(randomR, randomG, randomB); quad(290, 335, 260, 360, 275, 400, 315, 375); quad(270, 400, 240, 330, 200, 350, 230, 385); quad(260, 345, 315, 290, 310, 235, 275, 285); quad(255, 345, 245, 280, 200, 210, 215, 300); quad(260, 330, 250, 280, 200, 200, 270, 260); quad(275, 275, 310, 220, 360, 200, 290, 200); } else if (plantStage >= 17) { fill(randomR, randomG, randomB); quad(290, 335, 260, 360, 275, 400, 315, 375); quad(270, 400, 240, 330, 200, 350, 230, 385); quad(260, 345, 315, 290, 310, 235, 275, 285); quad(255, 345, 245, 280, 200, 210, 215, 300); quad(260, 330, 250, 280, 200, 200, 270, 260); quad(275, 275, 310, 220, 360, 200, 290, 200); //glowing part fill(114, 255, 231); stroke(255, 255, 255, random(30, 60)); strokeWeight(random(30, 50)); quad(270, 250, 290, 150, 200, 100, 200, 190); quad(290, 190, 370, 190, 380, 125, 300, 150); quad(205, 90, 270, 130, 310, 20, 240, 25); quad(280, 131, 320, 20, 390, 20, 380, 115); triangle(285, 135, 300, 145, 360, 125); } }//grows the third type of plant } else if (plantType == 2) { if (currentScene == 0) { if (plantStage == 1) { fill(167, 102, 193); triangle(245, 185, 230, 180, 245, 135); } else if (plantStage == 2) { fill(randomR, randomG, randomB); triangle(245, 185, 230, 180, 245, 135); triangle(242, 160, 240, 145, 215, 95); triangle(242, 160, 240, 175, 270, 160); triangle(245, 140, 230, 90, 250, 90); } else if (plantStage == 3) { fill(randomR, randomG, randomB); triangle(245, 185, 230, 180, 245, 135); triangle(242, 160, 240, 145, 215, 95); triangle(242, 160, 240, 175, 270, 160); triangle(245, 140, 230, 90, 250, 90); triangle(230, 90, 250, 90, 245, 50); triangle(245, 105, 280, 70, 245, 90); } else if (plantStage >= 4) { fill(randomR, randomG, randomB); triangle(245, 185, 230, 180, 245, 135); triangle(242, 160, 240, 145, 215, 95); triangle(242, 160, 240, 175, 270, 160); triangle(245, 140, 230, 90, 250, 90); triangle(230, 90, 250, 90, 245, 50); triangle(245, 105, 280, 70, 245, 90); triangle(235, 0, 270, 0, 245, 90); } } else if (currentScene == 1) { if (plantStage == 4) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); } else if (plantStage == 5) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); } else if (plantStage == 6) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); triangle(265, 290, 235, 280, 250, 210); triangle(255, 255, 260, 270, 280, 245); triangle(245, 245, 250, 230, 220, 205); } else if (plantStage == 7) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); triangle(265, 290, 235, 280, 250, 210); triangle(255, 255, 260, 270, 280, 245); triangle(245, 245, 250, 230, 220, 205); triangle(250, 215, 270, 175, 250, 170); triangle(255, 195, 260, 180, 285, 195); } else if (plantStage == 8) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); triangle(265, 290, 235, 280, 250, 210); triangle(255, 255, 260, 270, 280, 245); triangle(245, 245, 250, 230, 220, 205); triangle(250, 215, 270, 175, 250, 170); triangle(255, 195, 260, 180, 285, 195); triangle(245, 180, 270, 175, 235, 110); triangle(245, 175, 225, 175, 250, 160); } else if (plantStage == 9) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); triangle(265, 290, 235, 280, 250, 210); triangle(255, 255, 260, 270, 280, 245); triangle(245, 245, 250, 230, 220, 205); triangle(250, 215, 270, 175, 250, 170); triangle(255, 195, 260, 180, 285, 195); triangle(245, 180, 270, 175, 235, 110); triangle(245, 175, 225, 175, 250, 160); triangle(235, 110, 265, 70, 240, 65); } else if (plantStage == 10) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); triangle(265, 290, 235, 280, 250, 210); triangle(255, 255, 260, 270, 280, 245); triangle(245, 245, 250, 230, 220, 205); triangle(250, 215, 270, 175, 250, 170); triangle(255, 195, 260, 180, 285, 195); triangle(245, 180, 270, 175, 235, 110); triangle(245, 175, 225, 175, 250, 160); triangle(235, 110, 265, 70, 240, 65); triangle(255, 50, 265, 71, 240, 66); triangle(240, 75, 220, 65, 240, 90); } else if (plantStage == 11) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); triangle(265, 290, 235, 280, 250, 210); triangle(255, 255, 260, 270, 280, 245); triangle(245, 245, 250, 230, 220, 205); triangle(250, 215, 270, 175, 250, 170); triangle(255, 195, 260, 180, 285, 195); triangle(245, 180, 270, 175, 235, 110); triangle(245, 175, 225, 175, 250, 160); triangle(235, 110, 265, 70, 240, 65); triangle(255, 50, 265, 70.5, 240, 65.5); triangle(240, 75, 220, 65, 240, 90); triangle(255, 50, 240, 15, 260, 25); } else if (plantStage >= 12) { fill(randomR, randomG, randomB); triangle(235, 400, 270, 400, 265, 345); triangle(265, 320, 265, 335, 310, 325); triangle(250, 285, 270, 290, 265, 345); triangle(265, 290, 235, 280, 250, 210); triangle(255, 255, 260, 270, 280, 245); triangle(245, 245, 250, 230, 220, 205); triangle(250, 215, 270, 175, 250, 170); triangle(255, 195, 260, 180, 285, 195); triangle(245, 180, 270, 175, 235, 110); triangle(245, 175, 225, 175, 250, 160); triangle(235, 110, 265, 70, 240, 65); triangle(255, 50, 265, 71, 240, 66); triangle(240, 75, 220, 65, 240, 90); triangle(255, 50, 240, 15, 260, 25); triangle(245, 0, 240, 15.5, 260, 25.5); } } else if (currentScene == 2) { if (plantStage == 12) { fill(randomR, randomG, randomB); triangle(245, 400, 235, 380, 260, 375); } else if (plantStage == 13) { fill(randomR, randomG, randomB); triangle(245, 400, 235, 380, 260, 375); triangle(250, 320, 235, 380.5, 260, 375.5); triangle(250, 335, 245, 350, 230, 300); } else if (plantStage == 14) { fill(randomR, randomG, randomB); triangle(245, 400, 235, 380, 260, 375); triangle(250, 320, 235, 380.5, 260, 375.5); triangle(250, 320, 240, 240, 270, 210); triangle(250, 335, 245, 350, 230, 300); triangle(260, 265, 315, 280, 255, 285); } else if (plantStage == 15) { fill(randomR, randomG, randomB); triangle(245, 400, 235, 380, 260, 375); triangle(250, 320, 235, 380.5, 260, 375.5); triangle(250, 320, 240, 240, 270, 210); triangle(250, 335, 245, 350, 230, 300); triangle(260, 265, 315, 280, 255, 285); triangle(240, 240.7, 270, 210.7, 235, 125.5); } else if (plantStage == 16) { fill(randomR, randomG, randomB); triangle(245, 400, 235, 380, 260, 375); triangle(250, 320, 235, 380.5, 260, 375.5); triangle(250, 320, 240, 240, 270, 210); triangle(250, 335, 245, 350, 230, 300); triangle(260, 265, 315, 280, 255, 285); triangle(240, 240.7, 270, 210.7, 235, 125.5); triangle(210, 120, 250, 130, 230, 35); triangle(226, 117, 235, 127, 208, 156); triangle(225, 67, 150, 75, 225, 95); triangle(240, 95, 305, 115, 245, 125); } else if (plantStage >= 17) { fill(randomR, randomG, randomB); triangle(245, 400, 235, 380, 260, 375); triangle(250, 320, 235, 380.5, 260, 375.5); triangle(250, 320, 240, 240, 270, 210); triangle(250, 335, 245, 350, 230, 300); triangle(260, 265, 315, 280, 255, 285); triangle(240, 240.7, 270, 210.7, 235, 125.5); triangle(210, 120, 250, 130, 230, 35); triangle(226, 117, 235, 127, 208, 156); triangle(225, 67, 150, 75, 225, 95); triangle(240, 95, 305, 115, 245, 125); triangle(150, 65, 150, 85, 70, 81); triangle(145, 75, 170, 80, 160, 35); triangle(270, 105, 290, 115, 245, 80); //glowing part fill(114, 255, 231); stroke(255, 255, 255, random(30, 60)); strokeWeight(random(30, 50)); triangle(201, 81, 165, 120, 225, 120); triangle(201, 105, 240, 135, 190, 135); triangle(127, 98, 165, 75, 180, 100); triangle(91, 95, 110, 80, 115, 100); triangle(266, 127, 287, 122, 260, 112); triangle(286, 120, 286, 115, 292, 118); triangle(272, 290, 285, 280, 292, 291); } } } } //Displays on the screen what key on the keyboard the player should press to grow the plant. Draws a white box on the bottom left corner of the screen and stays there until //the plant has fully grown void keyIcon() { if (hasChosenPlant == true) { if (plantStage <17) { fill(255); rectMode(CORNERS); rect(10, 320, 80, 390); if (keyNumber == 0) { noFill(); stroke(133, 109, 198); strokeWeight(3); ellipseMode(CENTER); ellipse(45, 355, 30, 30); line(50, 360, 60, 370); } else if (keyNumber == 1) { noFill(); stroke(133, 109, 198); strokeWeight(3); line(25, 340, 35, 370); line(45, 350, 35, 370); line(45, 350, 55, 370); line(65, 340, 55, 370); } else if (keyNumber == 2) { noFill(); stroke(133, 109, 198); strokeWeight(3); line(30, 335, 30, 375); line(30, 335, 60, 335); line(60, 375, 30, 375); line(30, 355, 60, 355); } } } } //Generate random RGB values void generateRandomColours() { randomR = (int) random(100, 180); randomG = (int) random (100, 180); randomB = (int) random (200, 255); } //This function came all by accident when trying to code for randomized star locations. it turned out pretty cool so I decided to use it //as a water "particle" effect void waterEffect() { noStroke(); if (currentScene == 0) { rectMode(CENTER); fill(255 - random(0, 100), 255 - random(0, 40), 255 - random(0, 30), random(0, 50)); for (int i = 0; i <7; i++) { waterEffectLocation = random(0, 190); waterEffectHeight = random(0, 100); rect(waterEffectLocation, 300, 190, waterEffectHeight); } } } //Draws a repeating water pattern on the waterfall (took me forever to find out how to loop it properly for the scene and to make it look natural) void waterFall(float y) { noStroke(); if (currentScene == 0) { fill(255); for (int i = 0; i <5; i++) { arc(155 - (i*40), y, 50, 50, 0, PI); arc(155 - (i*40), y - 100, 50, 50, 0, PI); arc(155 - (i*40), y - 200, 50, 50, 0, PI); arc(155 - (i*40), y - 300, 50, 50, 0, PI); } } else if (currentScene == 1) { fill(255); for (int i = 0; i <5; i++) { arc(155 - (i*40), y, 50, 50, 0, PI); arc(155 - (i*40), y - 100, 50, 50, 0, PI); arc(155 - (i*40), y - 200, 50, 50, 0, PI); arc(155 - (i*40), y - 300, 50, 50, 0, PI); arc(155 - (i*40), y - 400, 50, 50, 0, PI); } } else if (currentScene == 2) { fill(255); for (int i = 0; i <5; i++) { arc(155 - (i*40), y, 50, 50, 0, PI); arc(155 - (i*40), y - 100, 50, 50, 0, PI); } } } //Resets the location of the water falling effect float waterFallYCalc() { waterFallY += 5; if (waterFallY > 400 && currentScene == 0) { waterFallY = 300; } else if (waterFallY > 400 && currentScene == 1) { waterFallY = 300; } else if (waterFallY > 400 && currentScene == 2) { waterFallY = 300; } return waterFallY; } //Changes the drawn background depending on the current scene void createSceneBackground() { rectMode(CORNER); ellipseMode(CENTER); if (currentScene == 0) { noStroke(); //background background(65 - plantStage*2, 87 - plantStage*2, 155 - plantStage*2); //background objects starGeneration(); fill(65, 187, 193); ellipse(260, 140, 200, 200); fill(78, 212, 219); rect(300, 0, 400, 200); fill(215, 240, 242); rect(370, 0, 400, 200); fill(108, 92, 178); quad(320, 200, 320, 120, 400, 60, 400, 200); quad(260, 120, 320, 140, 320, 200, 260, 200); quad(220, 140, 220, 200, 180, 240, 180, 180); plantGrowth(); //plant pot fill(31, 150, 144); rectMode(CORNERS); rect(229, 178, 250, 200); //ground rectMode(CORNER); fill(39, 99, 114); quad(220, 200, 400, 200, 400, 280, 120, 280); //water fill(64, 187, 221); rect(0, 280, 400, 400); //draw the background waves drawWavesBackground(backgroundWavesCalc()); drawWaterPlatformBack(waterPlatformBackCalc()); //water pillar left ellipseMode(CENTER); fill(117, 255, 252); rect(0, 0, 180, 340); waterFall(waterFallYCalc()); fill(255); rect(110, 0, 50, 330); //draw the foreground waves drawWavesForeground(foregroundWavesCalc()); drawWaterPlatformFore(waterPlatformForeCalc()); } else if (currentScene == 1) { noStroke(); //background background(65 - plantStage*2, 87 - plantStage*2, 155 - plantStage*2); starGeneration(); rectMode(CORNERS); fill(78, 212, 219); ellipse(360, 200, 120, 110); rect(300, 400, 400, 200); fill(215, 240, 242); rect(370, 400, 400, 200); ellipse(390, 200, 40, 50); //refreshes the plant growth drawing on the screen plantGrowth(); drawWaterPlatformBack(waterPlatformBackCalc()); //water pillar left ellipseMode(CENTER); fill(117, 255, 252); rect(0, 0, 180, 400); waterFall(waterFallYCalc()); fill(255); rectMode(CORNER); rect(110, 0, 50, 400); drawWaterPlatformFore(waterPlatformForeCalc()); } else if (currentScene == 2) { noStroke(); //background background(65 - plantStage*2, 87 - plantStage*2, 155 - plantStage*2); starGeneration(); rectMode(CORNERS); //water pillar left fill(117, 255, 252); rect(0, 400, 180, 210); plantGrowth(); waterFall(waterFallYCalc()); fill(255); rectMode(CORNER); rect(110, 220, 50, 400); //top of the water pillar stroke(255, 255, 255, random(30, 60)); strokeWeight(random(10, 15)); ellipse(80, 207, 200, 109); } //Displays the key taps icon keyIcon(); //If the player didn't choose a plant yet, the plant selection buttons will show on startup startPlantChoice(); } //Draws a slightly moving foreground water platform in the second scene and a shadow of it in the first scene void drawWaterPlatformFore(float a) { if (currentScene == 1) { fill(102, 247, 255); rectMode(CORNER); ellipseMode(CORNER); for (int i = 0; i < 1; i++) { ellipse(a, 230, 80, 50); rect(a, 200, 80, 50); fill(237, 252, 255); ellipse(a, 170, 80, 50); rect (a +45, 200, 30, 50); ellipse(a + 45, 235, 30, 30); } } else if (currentScene == 0) { ellipseMode(CORNER); fill(52, 130, 135, 50); for (int i = 0; i < 1; i++) { ellipse(a, 360, 80, 50); } } } //Calculates the foreground water platform's position and moves it accordingly float waterPlatformForeCalc() { if (waterPlatformForeTranslate == 0) { waterPlatformForeX -= 0.4; if (waterPlatformForeX < 50) { waterPlatformForeTranslate = 1; } } else if (waterPlatformForeTranslate == 1) { waterPlatformForeX += 0.4; if (waterPlatformForeX > 100) { waterPlatformForeTranslate = 0; } } return waterPlatformForeX; } //Draws a slightly moving background water platform in the second scene and a shadow of it in the first scene void drawWaterPlatformBack(float a) { if (currentScene == 1) { fill(127, 225, 232); rectMode(CORNER); ellipseMode(CORNER); for (int i = 0; i < 1; i++) { ellipse(a, 120, 100, 50); rect(a, 100, 100, 50); fill(237, 252, 255); ellipse(a, 75, 100, 50); rect (a +45, 100, 50, 50); ellipse(a + 45, 130, 50, 30); } } else if (currentScene == 0) { ellipseMode(CORNER); fill(52, 130, 135, 50); for (int i = 0; i < 1; i++) { ellipse(a, 270, 100, 50); } } } //Calculates the background water platform's postion and moves it accordingly float waterPlatformBackCalc() { if (waterPlatformBackTranslate == 0) { waterPlatformBackX -= 0.2; if (waterPlatformBackX < 150) { waterPlatformBackTranslate = 1; } } else if (waterPlatformBackTranslate == 1) { waterPlatformBackX += 0.2; if (waterPlatformBackX > 250) { waterPlatformBackTranslate = 0; } } return waterPlatformBackX; } //Creates a repeating pattern of waves in the foreground void drawWavesForeground(float a) { for (int i = 0; i < 12; i++) { fill(64, 187, 221); ellipse(a - i*30, 335, 40, 30); rectMode(CORNER); rect (0, 330, 400, 400); } } //Creates a repeating pattern of waves in the background. void drawWavesBackground(float a) { for (int i = 1; i < 12; i++) { fill(64, 187, 221, 20); ellipse(a - i*30, 270, 40, 30); fill(64, 187, 221, 40); ellipse(a - i*60, 270, 40, 30); fill(64, 187, 221); ellipse(a - i*30, 283, 40, 30); } } //Resets the position of the foreground waves float foregroundWavesCalc() { foregroundWavesX -= 1; if (foregroundWavesX < 180 && currentScene == 0) { foregroundWavesX = 270; } return foregroundWavesX; } //Resets the postion of the background waves float backgroundWavesCalc() { backgroundWavesX -= 2; if (backgroundWavesX < 440 && currentScene == 0) { backgroundWavesX = 500; } return backgroundWavesX; } //Draws an arrow pointing upwards or downwards depending on where the mouse cursor is located void drawArrow() { noStroke(); if (hasChosenPlant == true) { if (mouseY <= 49 && currentScene == 0) { fill(209, 25, 156, 255); rectMode(CENTER); triangle(mouseX, mouseY-10, mouseX-10, mouseY, mouseX+10, mouseY); rect(mouseX, mouseY+10, 5, 20); } else if (mouseY >= 350 && currentScene == 1) { fill(209, 25, 156, 255); rectMode(CENTER); triangle(mouseX, mouseY+10, mouseX-10, mouseY, mouseX+10, mouseY); rect(mouseX, mouseY-10, 5, 20); } else if (mouseY <= 49 && currentScene == 1) { fill(209, 25, 156, 255); rectMode(CENTER); triangle(mouseX, mouseY-10, mouseX-10, mouseY, mouseX+10, mouseY); rect(mouseX, mouseY+10, 5, 20); } else if (mouseY >= 350 && currentScene == 2) { fill(209, 25, 156, 255); rectMode(CENTER); triangle(mouseX, mouseY+10, mouseX-10, mouseY, mouseX+10, mouseY); rect(mouseX, mouseY-10, 5, 20); } } }