Skip to content

Commit

Permalink
fix ends the game when the snake hits its own body
Browse files Browse the repository at this point in the history
  • Loading branch information
s403o committed Mar 24, 2023
1 parent 4806aa0 commit d4dfb4f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d4dfb4f

Please sign in to comment.