No lecture. Today we will just be working on our midterm projects.
- Start Button – Run your board building function when clicked and start the timer.
- Tiles – Add a event listener for the click event for each tile and pass in a tile click function. These tiles should have a unique ID for each one, a data-id to detect if two are the same and a tile class to be able to reference the grouping of tiles.
- Counts – You should be tracking how many flips they do and how many flips are correct. You can do this by creating a global variable and initially setting that two equal 0. Then when you click on a tile simply add 1 to that variable using ++. In the if statement in the tile click logic function if you successfully match two tiles add 1 to the flips variable again using ++. Then pass the values to an HTML element using an ID.
- Timer – Use setInterval to create a timer. To display it on the game again create a global variable for the seconds and pass the value of that variable to an HTML element using an ID. To stop the clock if the game is over use clearInterval().
- Replay/Reset – At the end of the game display the play button again. When click it should reset the board, reset the timer and reset the click counts. To do this all you have to do is set those global variables back to 0 on click and reset the setInterval() clock with clearInterval().