💡Requirement Analysis
To design a game of Gluttony by setting the coordinates of the snake and changing the food coordinates, using C++ and calling the acllib library to implement the game graphically.
💡Key step-by-step instructions:
1、 Use the RGB function to set the colour of the snake, which can get more and more beautiful colours.
-
the use of arrays to initialise the length of the snake, and then arrays to achieve the change in length, using the random function srand to determine where the food appears.
-
The over function determines the death of two snakes, with appropriate explanations.
-
the keys were designed to be essentially ASCII to hexadecimal conversions.
-
Both the food and the snake morphology changes have calls to functions in the acllib library.
💡Test results Run the program and when the violet coloured snake wins, it will display VIOLET WIN.
Turquoise WIN will be displayed when the lake green snake wins.
When the two are of equal strength, it will show EQUAL!
💡Recommendations
1、This experiment is graphical, colours and shapes have been improved, and arrays and random numbers have been used to assign coordinates of snakes and food to move, which is a great gain for me.
2、The scoring system and the hierarchy can be added to make the game a better experience.
3、Graphic interface can be more beautiful, draw your own food pattern, and snake shape, so that the game is more realistic.
4、If you can design bombs, walls and other obstacles to increase the difficulty of the game, the playability will be improved.