- Include the different libraries necessary
- Create a struct which contains information about the player
- Create a character class that contains current and prior positions, and direction for the different characters on the screen.
- Assign a number value to a direction
- 0 – North
- 1 – East
- 2 – South
- 3 – West
- Create a struct for memory which stores all of the changing information in the game.
- The map describes the position of walls, free space, ghosts, oranges, and pac-man
- 0 – Free Space
- 1 – Wall
- 2 – Ghost
- 3 – Orange
- 4 – Pac-man
- Create a struct to hold a list of players with the their scores
- Create a class for the game which holds the different player names, leaderboard, memory, and functions for directions of characters.
- Write the function prototypes for displaying the menu, the game, the results, and the board. Also write prototypes for the map rendering, moving the ghosts and moving the pacman.
- Start the main function
- Set the orientation as north to give the desired orientation
- Seed the random number generator
- Initialize the game object
- Open the menu automatically
- End main function
- Start openRoute function
- Clear the screen and reset colors to default
- Run certain functions based on the route
- Route Types:
- 0 – Menu
- 1 – Play Game
- 2 – Game Session Results
- 3 – Leaderboard
- 4 – Instructions/Rules
- 5 – Credits
- Display the different options based on what is chosen
- End openRoute function
- Start the displayMenu function which renders the menu and responds to touches
- Set the number of options and text to show
- Draw vertical bounding lines for the menu
- Draw horizontal bounding lines for the menu
- Write out the options to the screen
- Wait for the user to touch something
- Record a touch and proceed after the finger has been removed
- Determine which option the user touched
- End the displayMenu function
- Start the displayPlay function which renders the game, responds to user interaction, and time-based changes
- Set up the map using the specification listed in the Memory struct
- Copy the default map into memory
- Each free space has a 40% chance of containing an orange
- Initialize all of the characters
- Store the characters to memory
- Initialize game state variables
- Initialize the time and touch variables
- Stop if the game has ended
- Change the UI to reflect the map in memory
- Wait for a user touch or a game tick
- If the event was a user touch, set the initial touch position
- Then set the final touch position
- Detect swipes via displacement of initial & final touch
- Conditions:
- Initial touch on map
- Swipe must be at least 15 px
- Check if east, west, north, or south swipe
- Detect 6 buttons at the bottom of the screen
- Buttons:
- Toggle pause
- Left
- Up
- Down
- Stop
- Right
- Reset the start time
- Move the ghosts randomly
- Move pacman in the specified direction
- Check if oranges remain on the board
- If there are no oranges, then the player wins and the game ends
- End the displayPlay function
- Start renderMap function
- Change each map square based on its type
- All map squares are 20px by 20px
- Draw a black box for free space
- Draw a white box for a wall
- Draw ghosts
- Draw pacman
- Draw the buttons at the bottom of the screen
- Start the modCoord function to modify the coordinates based on the direction
- End function
- Start the checkDirection function to check if the direction is off the board or a wall
- End function
- Start the onlyDirection function to check if the backwards direction is the only direction
- Loop through each direction to check
- Start the moveGhosts function to randomly move the ghosts to new positions
- Loop through each ghost
- Generate a random direction 0 to 3
- Reset the x and y coordinates to the current position
- Modify the x and y to the new coordinates
- If the direction is off screen or to a wall, regenerate a direction
- If the direction is backwards and it is not the only direction, regenerate
- Set current position to prior
- Update the memory variables
- Remove the ghost from the prior position
- Add the ghost to the new position
- End function
- Start movePacman function
- Set the x and y positions as the current ones
- If the new position is valid, change the coordinates
- Store the new positions to memory
- Remove pacman from the prior position
- Add the ghost to the new position
- End function
- Start displayResults function which renders the results of the game
- Display text based on game outcome
- Display the number of points earned
- Prompt the user to pick a name
- Write all of the professors & TAs to the screen
- Record a touch and proceed after the finger has been removed
- Detect pressing the professors and TAs, then proceed to the leaderboard
- End function
- Start displayBoard renders the leaderboard
- Display title and instructions
- Display the name and points of each professor and TA
- Record a touch and proceed after the finger has been removed
- Open the menu screen
- End function
- Start displayRules which explains how to play
- Write instructions to screen and continue if screen is tapped.
- End function
- Start displayCredits to attribute to the developers and rescources
- Write the instructions to the screen and continue when the screen is tapped
- End function