D. Final Algorithm, Flowchart, or Pseudocode

Pseudocode for Snake Game:

  1. Main script function “snake” that includes all of the code. This is called when the file is run in MATLAB
  2. Clear all the windows and variables
  3. Load the highscore file into a matrix to be read
  4. Load the audio files into memory
  5. Declare all the variables necessary for the project
  6. Create the main figure called disp
  7. Set the properties of disp
  8. Display the mainMenu prompt
  9. Set the initial snake_body positions and properties
  10. Plot the egg on the graph
  11. While currently =1
  12. Run countDown function
  13. While running=1
  14. Move the snake positions, draw the new snake in position, check for collisions, and then pause in order to establish a frame rate.
  15. While this entire program is running, check for the user input and if certain keys are pressed, either end the current game or rotate the snake
  16. End running loop once a collision is detected with itself, if collision with egg, add to score and move egg to new position while increasing snake length.
  17. Close Menu prompt (if you want to play again, and high scores)
  18. Reset the game
  19. End currently loop if the user prompts too, if not, reset and play again.
  20. Close all windows
  21. End

Pseudocode for Tron Game:

  1. Main script function “tron” that includes all of the code. This is called when the file is run in MATLAB
  2. Clear all the windows and variables
  3. Declare all the variables necessary for the project
  4. Create the main figure called disp
  5. Set the properties of disp
  6. Display the mainMenu prompt
  7. Set the initial player positions and properties
  8. While this entire program is running, check for the user input and if certain keys are pressed, either end the current game or rotate the appropriate player
  9. While neither player’s score is above 3
  10. If the player’s score is less than 3, run countDown and set up game and start
  11. Else, closeMenu prompt
  12. While there is no collision detected
  13. Move the players positions, draw the players in position, check for collisions, and then pause in order to establish a frame rate.
  14. End loop once a collision is detected with itself or with others, then add to the appropriate player’s score
  15. Close Menu prompt (if you want to play again, and high scores)
  16. Reset the game
  17. End currently loop if the user prompts too
  18. Close all windows
  19. End