Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing argument in Food class constructor #10

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

codez-bot[bot]
Copy link
Contributor

@codez-bot codez-bot bot commented Aug 17, 2023

Description

This PR fixes the issue where the Food class in snake_game_py/food.py was missing a required positional argument snake_segments in its __init__ method. This argument is used to ensure that the generated food position is not on the snake.

Summary of Changes

  • Added the snake_segments argument to the __init__ method of the Food class in snake_game_py/food.py.
  • Updated the generate method of the Food class to check if the potential food position is not in the snake segments before setting it as the food position.
  • No changes were made to the draw method of the Food class.

Please review and merge this PR. Thank you!

Fixes #8.


To checkout this PR branch, run the following command in your terminal:

git checkout sweep/fix-missing-argument_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.

@codez-bot codez-bot bot added the hi hibox your software chores label Aug 17, 2023
@codez-bot codez-bot bot mentioned this pull request Aug 17, 2023
Closed
2 tasks
@femto
Copy link
Owner

femto commented Aug 17, 2023

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'

@femto
Copy link
Owner

femto commented Aug 17, 2023

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'

@femto
Copy link
Owner

femto commented Aug 17, 2023

hi:retry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hi hibox your software chores
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hi:
1 participant