Project 6.1: Flood
Collect treasures amongst the growing puddles

REQUIREMENTS

  • Puddles

    • Your program should create 50 or more circular puddles on the screen

    • Each puddles should be assigned a random starting position when created

    • As time passes, the puddles grow in size

    • If the mouse touches a puddles , the player loses

  • Treasure

    • Treasure boxes are rectangles with a fixed size that appear at random locations

    • Players earn points for moving their mouse over treasure boxes

  • Reset

    • After 5 seconds, the game goes to a new stage

    • On the new stage, all puddles are reset

    • Puddles grow faster on more advanced stages

STEP BY STEP

1) Draw Puddles

        • Puddle objects have an x position, y position, and size.

        • Puddle objects have a constructor that sets x and y randomly

        • Puddle objects have a render() method that draws a blue ellipse based on x, y, and size

      • In main, create an array of water objects and call render() every frame

2) Growing Puddles

      • Add an update method to each puddle

        • Increase the puddle's size

      • Make sure to call update in main every frame

3) Game Over!

      • Add a boolean variable to your main tab called gameOver, and start it as false.

      • A puddle's update method should only be called when the game is not over.

      • Add code to the update method that detects when the user's mouse is touching the puddle.

      • In your draw() method, add code that displays a message to the user if the game is over.

4) Adding Treasure

      • Create a class to represent treasure boxes and add it to the main program appropriately

      • Treasures should be brown rectangles.

      • When a treasure is in the area of a puddle, only the puddle should be shown

        • Hint: Think about the order you draw things in

5) Collecting Treasure

      • Add a boolean variable to your Treasure class called collected.

      • In update, when the mouse touches the treasure, set collected to true.

        • Since treasure is a rectangle, we can't just check distance from the X, Y, since that's the top left corner. It'd always register off-center. An okay solution would be distance from the middle. But then we'd be treating the box like a circle. A better solution would be to check if you're within all four sides.

        • Take a look at the Coder's Handbook: Mouseover and Clicks for more advice.

      • In render, only draw treasures that have not been picked up

6) Points For Treasure!

      • Add a variable called score to your main program. Remember: It belongs in main because there's only one score in the entire program. Puddles and Treasures do not get their own scores!

      • Display score in the top-left corner of the screen at all times.

      • When your mouse is over a treasure, add one to score in addition to marking it as collected.

      • Add an additional requirement to your mouseover: a treasure can only be collected if it has not already been collected. You'll need to use the && operator for this.

7) New Levels

      • Create a variable called level in your main program. Start it at zero.

      • Add code to display the level in the top left corner of the screen near score.

      • Create a variable called timer in your main program. Every frame, increase timer by one. Once the timer reaches 300 frames (5 seconds), call a method called reset().

      • In the reset method, put all the code from the setup() that initializes the elements of each array. Increase level by one. Set timer to zero. You can call reset() in your constructor now instead of putting that code in two places!


8) Difficulty Scaling

      • Change the puddle's growth speed based on the level.

EXTRA CREDIT

Earning Extra Credit

      • A project that adds substantial functionality and/or polish can earn up to 10% extra credit.

      • Some suggestions are below. Feel free to use them or add your own.

      • The amount of features needed to earn points is subjective and won't be revealed until grading. Just make it as cool as you can!

Ideas

      • Make your program only start moving once the user has clicked the screen (or a start button)

      • Every level has a different color scheme for background, puddles, and treasures.

      • Create a new theme for your project and use images instead of simple shapes.

      • Create alternate hazards that move around the screen or grow in different ways from puddles.

      • Create additional rewards that provide points ot benefits that are different from treasures.

EXAMPLE: RUNNING PROGRAM

Click here to download a running version of the program. <COMING SOON>

EXCEPTIONAL STUDENT PROJECTS

Turbulence | Download
by Mohammed Ibrahim (2022)

      • Title Screen

      • Tornados

      • Pixel Art

      • Sound Effects