Code Representation: Pseudocode

This page includes the Pseudocode for the flow of Grass Simulator 2018.

Pseudocode for main:

  1. Start.
  2. Initialize Events class called events, includes functions used.
  3. Initialize variable used for the menus and playing the game.
  4. Display main menu.
  5. Wait for touch and release of screen
  6. Run the code for pressed option from the player (play game, instructions, options, statistics, credits, or quit).
  7. If “play game” pressed:
    1. Initialize any additional variables used for the game.
    2. Start gameplay.
    3. Display current state of grass and current day.
    4. Calculate random number.
    5. If random number in a certain interval, display that random event and its options.
    6. Wait for touch and release of screen.
    7. Display results of pressed option.
    8. Display in-game menu.
    9. Wait for touch and release of screen.
    10. If a grass tending option is pressed, display current grass, the animation, and then the updated grass.
    11. If “quit current run” option is chosen, display “game over” screen and return to main menu.
    12. If grassHealth = 0, demerits = x, or grassHeight > 35, display “game over” screen and return to main menu.
    13. Increment day counter and return to gameplay start.
  8. If “instructions” pressed:
    1. Display instructions for the game.
    2. Wait for touch and release of screen.
    3. Return to main menu.
  9. If “options” pressed:
    1. Display options menu.
    2. Wait for touch and release of screen.
    3. When an option is chosen, move the black block next to the chosen difficulty/option and adjust the variable/function associated with that difficulty/option.
    4. Stay on menu when an option is chosen.
    5. If “go back” is pressed, return to main menu.
  10. If “statistics” is pressed:
    1. Display current statistics.
    2. Wait for touch and release of screen.
    3. If “RESET STATS” pressed, set all stats to zero and return to main menu.
    4. If elsewhere pressed return to main menu.
  11. If “credits” pressed:
    1. Display credits including members, team name, and inspirations.
    2. Wait for touch and release of screen.
    3. Return to main menu.
  12. If “quit” pressed:
    1. Clear screen.
    2. Display end game screen.
  13. If anywhere else is pressed return to main menu
  14. Stop.