0% found this document useful (0 votes)
19 views1 page

Algorithm 241i360

The document outlines the steps to create a snake game algorithm including adding libraries, creating classes, prototyping functions, generating a main loop, handling input, movement, collision detection, displaying the leaderboard and defining supporting functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Algorithm 241i360

The document outlines the steps to create a snake game algorithm including adding libraries, creating classes, prototyping functions, generating a main loop, handling input, movement, collision detection, displaying the leaderboard and defining supporting functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Algorithm

1. Add libraries needed, making sure to include the Proteus ones.


2. Create classes that are needed. These are Leaderboard, Vector, Food,
SnakeDot, Snake
3. Create Prototypes for need functions. This are draw border, menufolder,
checkdeath, leaderboard, rulesdisplay, regenfood.
4. Create main.
5. Make a large while loop to contain the entire game.
6. Reference the menufolder function.
7. Run the game within a while loop.
8. Generate food positions using srand.
9. Add boarders using drawboarder.
10.Reference input to move snake.
11.Clear snake off the screen.
12.Redraw snake to make changes based on input.
13.Check if the snake is colliding with itself or wall.
14.Show leaderboard after death.
15.End the main.
16.Define functions.
17.Vector function makes initial snake and moves the body of the snake into
the location of the piece in front of it.
18.Snake function draws the green body of the snake.
19.Add function makes the snake move in the direction of the key input.
20.Equals function checks to see if the snake is colliding with anything.
21. Draw functions draw food made earlier, snake, or input.
22. GetInput function looks for button input from the user.
23.Update function updates the location of the snake.
24.Checkdeath function will look to see if any of the death conditions are being
met.
25.Drawborder function looks to see if the snake is colliding with the outside
walls.
26.Menufolder shows the menu and the menu and selects gameplay option.
27.Rulesdisplay function shows the rules for the game.
28.Leaderboard function shows the top 50 scores.

You might also like