Skip to content

Commit 0983158

Browse files
committed
Update Project_Snake_Game/snake-game.cpp in branch Precogs-fix-ifx7kj0k
1 parent 018d1b4 commit 0983158

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Project_Snake_Game/snake-game.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,26 @@ void welcome() {
230230
}
231231

232232
void instructions() {
233-
system("cls");
234-
cout << endl << endl << endl << endl << endl << endl << endl;
235-
cout << " ";
236-
cout << "Welcome to the snake game!" << endl;
237-
cout << endl;
238-
cout << " " << "Here are instructions" << endl;
239-
cout << " " << "1. If you reach current record you won the game" << endl;
240-
cout << endl;
241-
cout << " " << "2. When you grow up in size you cannot touch yourself, " << endl << " " << "if you touch you will lose the game" << endl;
242-
cout << endl;
243-
cout << " " << "3. When you grow up in size you cannot touch yourself," << endl << " " << "if you move backwards when you body is backward" << endl << " " << "you automatically lose the game" << endl;
244-
cout << endl;
245-
char back;
246-
cout << " " << "To go back press any key" << endl;
247-
cin >> back;
248-
if (back) welcome();
233+
#if defined(_WIN32) || defined(_WIN64)
234+
system("cls"); // Clear screen for Windows
235+
#else
236+
system("clear"); // Clear screen for Unix/Linux
237+
#endif
238+
cout << endl << endl << endl << endl << endl << endl << endl;
239+
cout << " ";
240+
cout << "Welcome to the snake game!" << endl;
241+
cout << endl;
242+
cout << " " << "Here are instructions" << endl;
243+
cout << " " << "1. If you reach current record you won the game" << endl;
244+
cout << endl;
245+
cout << " " << "2. When you grow up in size you cannot touch yourself, " << endl << " " << "if you touch you will lose the game" << endl;
246+
cout << endl;
247+
cout << " " << "3. When you grow up in size you cannot touch yourself," << endl << " " << "if you move backwards when you body is backward" << endl << " " << "you automatically lose the game" << endl;
248+
cout << endl;
249+
char back;
250+
cout << " " << "To go back press any key" << endl;
251+
cin >> back;
252+
if (back) welcome();
249253
}
250254

251255
void record() {

0 commit comments

Comments
 (0)