C. Code Representation (Algorithm, Flowchart, or Pseudocode)

Algorithm

  • Initialize the screen with a main menu containing:
    1. 3 buttons for 3 different save slots
    2. A high score button
    3. An instructions/credits button
    4. A quit button
  • Initialize an srand() statement
  • When a save slot button is hit:
    1. An instance of the class User is created
    2. The score counter in the main function is set to zero
    3. For 15 times:
      1. The screen and color written on the screen are randomly generated
      2. 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
  1. 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
  2. If the colors don’t match and the user taps the screen, the compare function returns a value of 5 seconds
  3. 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
  1. 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
  2. A thanks for playing screen appears on the screen
    1. “thanks for playing” is written on one line
    2. “your score is ###” is written on the next line
  • The screen stays up for 5 seconds
  1. The screen is cleared and the main menu function is run again
  • When the high scores button is pressed:
    1. The screen is cleared
    2. The 3 scores (one from each User instance) is passed into the highscore function
    3. The scores are sorted using premade if/else if statements to determine the correct order of scores
    4. The order of users and their scores are printed to the screen
    5. When the screen is touched, the screen clears and the main menu function is run again
  • When the instructions button is pressed:
    1. The screen is cleared
    2. Instructions on how to play the game
    3. Credits for game developers are also written to the screen
    4. 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:
    1. The normal looping function that returns the program to the main menu function is broken and the program ends