Skip to content

fixes direction reversing#4

Closed
ScriptkidHicks wants to merge 1 commit into
patrickloeber:masterfrom
ScriptkidHicks:master
Closed

fixes direction reversing#4
ScriptkidHicks wants to merge 1 commit into
patrickloeber:masterfrom
ScriptkidHicks:master

Conversation

@ScriptkidHicks
Copy link
Copy Markdown

This change prevents the snake from reversing directly into the tail behind it.

Copy link
Copy Markdown
Owner

@patrickloeber patrickloeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. Please simplify the if statements a little bit

if event.key == pygame.K_LEFT:
self.direction = Direction.LEFT
if self.direction == Direction.RIGHT:
self.direction == Direction.RIGHT
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=, not ==. Also, this is a little bit too much unnecessary code. You can simply use if self.direction != Direction.RIGHT

@ScriptkidHicks ScriptkidHicks closed this by deleting the head repository Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants