Algorithm
- Initialize the screen with a main menu containing:
- 3 buttons for 3 different save slots
- A high score button
- An instructions/credits button
- A quit button
- Initialize an srand() statement
- When a save slot button is hit:
- An instance of the class User is created
- The score counter in the main function is set to zero
- For 15 times:
- The screen and color written on the screen are randomly generated
- The 2 colors are compared and the program waits 5 seconds for the user to choose an action
- If the colors match and the user taps the screen, their reaction time is recorded and the compare function returns the reaction time
- If the colors don’t match and the user tilts the Proteus, their reaction time is recorded and the compare function returns the reaction time
- If the colors don’t match and the user taps the screen, the compare function returns a value of 5 seconds
- If the colors match and the user tilts the Proteus, the compare function returns a value of 5 seconds
- The score counter in the main function is incremented by the returned reaction time and the screen is cleared
- The user’s score is sent to the class User in the current player’s instance and their score is saved in the main function as well
- A thanks for playing screen appears on the screen
- “thanks for playing” is written on one line
- “your score is ###” is written on the next line
- The screen stays up for 5 seconds
- The screen is cleared and the main menu function is run again
- When the high scores button is pressed:
- The screen is cleared
- The 3 scores (one from each User instance) is passed into the highscore function
- The scores are sorted using premade if/else if statements to determine the correct order of scores
- The order of users and their scores are printed to the screen
- When the screen is touched, the screen clears and the main menu function is run again
- When the instructions button is pressed:
- The screen is cleared
- Instructions on how to play the game
- Credits for game developers are also written to the screen
- When the user taps the screen again, the screen is cleared and the main menu function is run again
- When the quit button is pressed:
- The normal looping function that returns the program to the main menu function is broken and the program ends