This PR introduces an enemy snake to the game, making it more challenging and engaging. The enemy snake moves autonomously, following simple AI patterns such as chasing food or avoiding the player's snake. It can eat food, grow, and cause a game over if it collides with the player's snake. The main game loop, rendering function, and other relevant parts of the code have been updated to accommodate this new feature.
Summary
Added EnemySnake class: A new class EnemySnake has been added to snake.py, inheriting from the existing Snake class. It overrides the move method to implement autonomous movement logic and includes a method to check for collisions with the player's snake.
Updated Game class: The Game class in game.py has been modified to include an instance of EnemySnake. The update method has been updated to move the enemy snake and check for collisions between the player's snake and the enemy snake. The render method has also been updated to draw the enemy snake on the screen.
Modified main game loop: The main game loop in main.py has been updated to initialize and manage the enemy snake alongside the player's snake.
Added unit tests: New unit tests have been added to tests.py to validate the behavior of the EnemySnake class, including its autonomous movement and collision detection with the player's snake.
Enhanced Gameplay: With the addition of the enemy snake, the game now offers a more dynamic and challenging experience, aligning with the goal of creating an engaging and user-friendly Snake game.
This enhancement aligns with the user's desire for a more fun and challenging game experience, as described in issue #24. It has been implemented with careful consideration of modularity, performance, and user experience, following the design principles outlined in the system design document.
Please review and provide feedback on these changes. Thank you!
Fixes #24.
To checkout this PR branch, run the following command in your terminal:
git checkout sweep/enemy-snake_1
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.
Description
This PR introduces an enemy snake to the game, making it more challenging and engaging. The enemy snake moves autonomously, following simple AI patterns such as chasing food or avoiding the player's snake. It can eat food, grow, and cause a game over if it collides with the player's snake. The main game loop, rendering function, and other relevant parts of the code have been updated to accommodate this new feature.
Summary
EnemySnake
has been added tosnake.py
, inheriting from the existingSnake
class. It overrides themove
method to implement autonomous movement logic and includes a method to check for collisions with the player's snake.Game
class ingame.py
has been modified to include an instance ofEnemySnake
. Theupdate
method has been updated to move the enemy snake and check for collisions between the player's snake and the enemy snake. Therender
method has also been updated to draw the enemy snake on the screen.main.py
has been updated to initialize and manage the enemy snake alongside the player's snake.tests.py
to validate the behavior of theEnemySnake
class, including its autonomous movement and collision detection with the player's snake.This enhancement aligns with the user's desire for a more fun and challenging game experience, as described in issue #24. It has been implemented with careful consideration of modularity, performance, and user experience, following the design principles outlined in the system design document.
Please review and provide feedback on these changes. Thank you!
Fixes #24.
To checkout this PR branch, run the following command in your terminal:
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.