From 09831581c4414e86ba0e1cbed74b90cf57042603 Mon Sep 17 00:00:00 2001 From: Sameer <142401625+sameer6pre@users.noreply.github.com> Date: Wed, 23 Jul 2025 15:07:34 +0530 Subject: [PATCH] Update Project_Snake_Game/snake-game.cpp in branch Precogs-fix-ifx7kj0k --- Project_Snake_Game/snake-game.cpp | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Project_Snake_Game/snake-game.cpp b/Project_Snake_Game/snake-game.cpp index 469cb6d..434b36b 100644 --- a/Project_Snake_Game/snake-game.cpp +++ b/Project_Snake_Game/snake-game.cpp @@ -230,22 +230,26 @@ void welcome() { } void instructions() { - system("cls"); - cout << endl << endl << endl << endl << endl << endl << endl; - cout << " "; - cout << "Welcome to the snake game!" << endl; - cout << endl; - cout << " " << "Here are instructions" << endl; - cout << " " << "1. If you reach current record you won the game" << endl; - cout << endl; - cout << " " << "2. When you grow up in size you cannot touch yourself, " << endl << " " << "if you touch you will lose the game" << endl; - cout << endl; - 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; - cout << endl; - char back; - cout << " " << "To go back press any key" << endl; - cin >> back; - if (back) welcome(); + #if defined(_WIN32) || defined(_WIN64) + system("cls"); // Clear screen for Windows + #else + system("clear"); // Clear screen for Unix/Linux + #endif + cout << endl << endl << endl << endl << endl << endl << endl; + cout << " "; + cout << "Welcome to the snake game!" << endl; + cout << endl; + cout << " " << "Here are instructions" << endl; + cout << " " << "1. If you reach current record you won the game" << endl; + cout << endl; + cout << " " << "2. When you grow up in size you cannot touch yourself, " << endl << " " << "if you touch you will lose the game" << endl; + cout << endl; + 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; + cout << endl; + char back; + cout << " " << "To go back press any key" << endl; + cin >> back; + if (back) welcome(); } void record() {