From 6b18f669e22ee8797e038efbea85cd6b20714e91 Mon Sep 17 00:00:00 2001 From: Sameer <142401625+sameer6pre@users.noreply.github.com> Date: Wed, 23 Jul 2025 15:08:04 +0530 Subject: [PATCH] Update Project_Snake_Game/snake-game.cpp in branch Precogs-fix-urwl5una --- Project_Snake_Game/snake-game.cpp | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Project_Snake_Game/snake-game.cpp b/Project_Snake_Game/snake-game.cpp index 469cb6d..8574def 100644 --- a/Project_Snake_Game/snake-game.cpp +++ b/Project_Snake_Game/snake-game.cpp @@ -273,21 +273,25 @@ void incorrectChoice() { if (back) welcome(); } void lostgame() { - game = false; - system("cls"); - cout << endl << endl << endl << endl << endl << endl << endl; - cout << " "; - cout << "Sorry you lost the game " << endl; - cout << " " << "Your score was " << score << endl; - cout << " "; - cout << "To to back press any button" << endl; - char back; - cin >> back; - if (back) { - game = false; - welcome(); - } - + game = false; + // FIX: Use a platform-specific API to clear the screen instead of system("cls") + #ifdef _WIN32 + system("cls"); // Windows-specific clear screen + #else + system("clear"); // Unix/Linux-specific clear screen + #endif + cout << endl << endl << endl << endl << endl << endl << endl; + cout << " "; + cout << "Sorry you lost the game " << endl; + cout << " " << "Your score was " << score << endl; + cout << " "; + cout << "To to back press any button" << endl; + char back; + cin >> back; + if (back) { + game = false; + welcome(); + } } int main() {