From d4dfb4fd996f526c6053dce8f5216ddd5319eb74 Mon Sep 17 00:00:00 2001 From: s403o Date: Sat, 25 Mar 2023 00:10:08 +0200 Subject: [PATCH] fix ends the game when the snake hits its own body --- main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.cpp b/main.cpp index 07da4c7..34b3ace 100644 --- a/main.cpp +++ b/main.cpp @@ -131,6 +131,13 @@ void DrawSnake() } food = true; } + for(int j = 1; j < snake_len; j++) + { + if(posX[j] == posX[0] && posY[j] == posY[0]) + { + gameOver = true; + } + } } void DrawFood()