Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- The Snake Game Cleanup - The final code needs to be able to work in Visual Studio in C++ keep that in kind. -

image text in transcribedimage text in transcribed

- The Snake Game Cleanup

- The final code needs to be able to work in Visual Studio in C++ keep that in kind.

- Answer is not correct unless you have completed everything on the lists not just one thing.

- Make sure to add comments to note exactly all changes to made to the code.

- The C++ source code below needs to be used as a base to implement these things:

#include #include #include using namespace std; bool gameOver; const int width = 20; const int height = 20; int x, y, fruitX, fruitY, score; int tailX[100], tailY[100]; int nTail; enum eDirecton { STOP = 0, LEFT, RIGHT, UP, DOWN}; eDirecton dir; void Setup() { gameOver = false; dir = STOP; x = width / 2; y = height / 2; fruitX = rand() % width; fruitY = rand() % height; score = 0; } void Draw() { system("cls"); //system("clear"); for (int i = 0; i  width || x  height || y = width) x = 0; else if (x = height) y = 0; else if (y   Objective: Modify and Extend the SnakeGame program in the following ways: 1. Improve the code wherever you think it needs to be improved for clarity or comprehensibility. Show me what you know about good programming structure and style. (You have probably already done most of this work in Homework O.) 2. Is there a bug in the board drawing code that sometimes makes the snake disappear? If there is, find it and fix it. There may be other bugs in either the Logic or Draw routines; find any and fix them. 3. The Logic routine is too complicated for easy understandability. For example, it addresses two separate concerns. Fix this by separation of concerns. 4. The snake growing part of the Logic routine is poorly written - unclear variable names, no commentary, and obscure logic. Fix these issues to the best of your ability. 5. Add the capability of having more than one fruit on the board. Create some variable and set it to a value of 2 to 5, say, to represent the number of fruits that should be on the board. You can either hardwire the number of fruits or ask the user for a number at the beginning of the program. Create a new fruit for each fruit that is eaten. 6. Add an option to let the user play another game when he loses rather than just exiting the program when the user fails. 7. Add an input option P that pauses the game and waits for the user to hit any other key before proceeding. 8. When the program first starts, print out some instructions for using the game to the user. 9. Add an option to the game that makes the player lose the game if the snake hits a wall. 10. Make the input routine case-insensitive. 11. Add any other features you think are valuable/interesting, and note in the comments at the top of the program what you added and why. 12. Use good debugging techniques, but leave the comments in the program when you submit it; just comment out the debugging code. Annotations for the code: 1. The main function can be at either the beginning or the end of the program. I don't care which. 2. Add comments at the top of your main.cpp file to include your name, the name of the program, and notes on what changes and improvements you made to the program. (For example, list what bugs you fixed, what new features you added, what code you improved, and so on.) 3. Comment your code effectively, as we discussed in class. Use descriptive variable names everywhere so that the code becomes as self-documenting as possible. Use additional commentary to improve readability and comprehensibility by other people. 4. You absolutely MUST use consistent indentation and coding styles throughout the program. Failure to do so will result in a loss of 5 points. 5. If the program does not work at all, or works incorrectly, 10 points will be deducted.  Objective: Modify and Extend the SnakeGame program in the following ways: 1. Improve the code wherever you think it needs to be improved for clarity or comprehensibility. Show me what you know about good programming structure and style. (You have probably already done most of this work in Homework O.) 2. Is there a bug in the board drawing code that sometimes makes the snake disappear? If there is, find it and fix it. There may be other bugs in either the Logic or Draw routines; find any and fix them. 3. The Logic routine is too complicated for easy understandability. For example, it addresses two separate concerns. Fix this by separation of concerns. 4. The snake growing part of the Logic routine is poorly written - unclear variable names, no commentary, and obscure logic. Fix these issues to the best of your ability. 5. Add the capability of having more than one fruit on the board. Create some variable and set it to a value of 2 to 5, say, to represent the number of fruits that should be on the board. You can either hardwire the number of fruits or ask the user for a number at the beginning of the program. Create a new fruit for each fruit that is eaten. 6. Add an option to let the user play another game when he loses rather than just exiting the program when the user fails. 7. Add an input option P that pauses the game and waits for the user to hit any other key before proceeding. 8. When the program first starts, print out some instructions for using the game to the user. 9. Add an option to the game that makes the player lose the game if the snake hits a wall. 10. Make the input routine case-insensitive. 11. Add any other features you think are valuable/interesting, and note in the comments at the top of the program what you added and why. 12. Use good debugging techniques, but leave the comments in the program when you submit it; just comment out the debugging code. Annotations for the code: 1. The main function can be at either the beginning or the end of the program. I don't care which. 2. Add comments at the top of your main.cpp file to include your name, the name of the program, and notes on what changes and improvements you made to the program. (For example, list what bugs you fixed, what new features you added, what code you improved, and so on.) 3. Comment your code effectively, as we discussed in class. Use descriptive variable names everywhere so that the code becomes as self-documenting as possible. Use additional commentary to improve readability and comprehensibility by other people. 4. You absolutely MUST use consistent indentation and coding styles throughout the program. Failure to do so will result in a loss of 5 points. 5. If the program does not work at all, or works incorrectly, 10 points will be deducted

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions