Open codez-bot[bot] opened 1 year ago
Traceback (most recent call last):
File "/Users/femtozheng/python-project/snake_game_py/main.py", line 80, in
Traceback (most recent call last): File "/Users/femtozheng/python-project/snake_game_py/main.py", line 80, in game = Game() ^^^^^^ File "/Users/femtozheng/python-project/snake_game_py/main.py", line 22, in init self.food = Food() ^^^^^^ TypeError: Food.init() missing 1 required positional argument: 'snake_segments'
hi:retry
Description
This PR fixes the issue where the
Food
class insnake_game_py/food.py
was missing a required positional argumentsnake_segments
in its__init__
method. This argument is used to ensure that the generated food position is not on the snake.Summary of Changes
snake_segments
argument to the__init__
method of theFood
class insnake_game_py/food.py
.generate
method of theFood
class to check if the potential food position is not in the snake segments before setting it as the food position.draw
method of theFood
class.Please review and merge this PR. Thank you!
Fixes #8.
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.