Whack-a-mole
#
SummaryThe aim of this exercise is to think about how to solve a problem without actually thinking how to solve it using any programming language.
We want to implement a game which consist in smashing some moles
#
Requirements- The moles will show up from several holes in the ground.
- We need a button to allow the player to start the game
- A counter will hold the player's score
- There's a timer. When the timer reaches 0; the game ends.
- The moles will appear randomly and at different speed levels while there's game time remaining.
- When the time is over, moles stop popping up, and display a message of end with your score.
#
Future requeriments- The holes could be replaced by different landscapes
- The user could set up the game's level
- Number of holes
- Min and max speed of mole's animation
- Game time
- It could be fancy that all the moles show up before game starts. After game starts, all moles will hide.
- Allow to the user to set up the timer's visibility.
- When "Start" button pressed, we hide it and we display a "Restart" button
- Scoreboard on localStorage
- Save the score
- Save username with input will display at the end of game
#
Configuration and state managementWhich variables could be useful to hold our app state?
- Score
- Every succesfull hit on a mole, score goes one up
- Restart the game, updates counter to 0
- Remaining game time
- When the game restarts, the timer get the value of initial game time
- Every second gets updated
- Game state: ready, end, playing
- Ready: When the game loads and before user clicking "Start"
- End: When the time finishes
- Playing: User clicks "Start" button
- Next hole in which the mole will appear
- When the previous mole finishes the showing animation, we calculate a new hole.
- Max and min speed mole
- Number of holes
- Initial game time
#
User interface and DOM manipulation#
Start- Pressing the "Start" button initialize the game
#
Score- We will use a textual counter inicialized at 0, and every time the user succesfully clicks a mole, the counter will get upgraded by one.
- At pressing the start button again to restart the game, the counter will get automatically updated to 0.
#
Moles- Before starting the game, under the start button, the user will see a grid system that will display the holes and moles ready for starting the game
- When we start the game, we will hide the moles, and they will start popping up randomly and get ready to get clicked.
#
End Message- At the end of game, we show a message with the total score of the user