lesson-cover

Go Back

Front End Engineering

Lights Off

Create a simple game. Demo

Hint The game starts with one light turned on. When you click on it, it toggles (therefore turning off), and its surrounding lights (up, down, left right) will also toggle. The game ends when all the lights are turned off.

  • Acceptance Criteria

    • You should detect when game is over (all lights are off).
    • At the end of the game, user should be able to input a new size for the board and replay the game.

  • Steps and Points

    • (40 points) Create a 2D array of Block objects that displays blocks on the page.
    • (20 points) When a lit block is clicked, trigger neighbors to toggle (if already lit up, then make it light off; if already lit off, then make it light up) (using the 2D array). When a non lit block is clicked, nothing happens.
    • (20 points) Add a check for game to be over.
    • (20 points) Wrap code into a create game function.