[x] Bug fix (non-breaking change which fixes an issue)
👨‍💻 Changes proposed:
In the play method of your Game class, I changed the starting index of the loop that checks for collisions between the snake’s head and its body.
Originally, your code started checking for collisions from the third segment of the snake’s body (for i in range(3, self.snake.length)). This means that when the length of the snake is less than 3, the collision detection with the snake’s body is not performed.
I modified this to start checking from the first segment of the snake’s body instead (for i in range(1, self.snake.length)). This ensures that the collision detection with the snake’s body is always performed, regardless of the length of the snake.
✔️ Check List (Check all the applicable boxes)
[x] My code follows the code style of this project.
[x] This PR does not contain plagiarized content.
[x] The title of my pull request is a short description of the requested changes.
[x] I have included comments in areas that may be difficult to understand.
[x] My changes have not introduced any new warnings.
fixed issue #27
🛠️ Fixes Issue: Collisions
Type of change ✍️
👨‍💻 Changes proposed:
In the
play
method of your Game class, I changed the starting index of the loop that checks for collisions between the snake’s head and its body.Originally, your code started checking for collisions from the third segment of the snake’s body
(for i in range(3, self.snake.length))
. This means that when the length of the snake is less than 3, the collision detection with the snake’s body is not performed.I modified this to start checking from the first segment of the snake’s body instead
(for i in range(1, self.snake.length))
. This ensures that the collision detection with the snake’s body is always performed, regardless of the length of the snake.✔️ Check List (Check all the applicable boxes)
đź“· Screenshots
N/A
đź“„ Note to reviewers
N/A