Unit 2 Response & Draw
How can control flow allow for user interactions?

Mini-Project - Light Switch Game


Prompt

Congratulations! Your great aunt’s second cousin twice removed (on your mother’s side) has recently left you a spooky old house. This is great, because “free house”. As you can imagine, however, this does come with its fair share of problems, because spooky, and old.

The biggest problem your great aunt’s second cousin twice removed’s attorney warns you about when handing over the deed is that the wiring in the house is pretty old and nonsensical. Sometimes, a light switch controls multiple lights: it might turn more than one light on at a time, and will also turn some lights off. Because the house is spooky, you need to figure out how to turn all of the lights on as quickly as possible.

The attorney recommends you try to make this into a game to help you practice and to distract you from the dark foreboding shadows that definitely are not hiding anything you need to worry about (but let’s turn the lights on just in case?).

Create a p5 program that will have at least 6 buttons - your light switches. Each light switch should control several other lights, and maybe also the light you clicked. Create a solvable puzzle game in which you need to find the right order to press the switches so all lights are turned on at once.

Requirements

Work with a partner to complete the following:

  1. Create a game with at least six clickable buttons.
  2. Create a flowchart of your game so you can guarantee that there is a combination of switches that you can click to turn them all on, solving the puzzle.
  3. Create a p5 program where each switch turns a combination of lights on and/or off.
  4. Add any necessary design elements to make this game look appealing!

Writing Prompt

Describe your design process, including stepping through the code to explain exactly how to reach a solution and why your solution works.

Extensions

  • Figure out how to draw a new background and “scene” if you win, so that the player knows they have completed the challenge.
  • Figure out how to keep score, and make something happen if the user has clicked too many times without solving the puzzle.