Show HN: Reverse Snake (PyGame)

(github.com)

1 points | by DavidCanHelp 10 hours ago ago

3 comments

  • 9 hours ago ago
    [deleted]
  • DavidCanHelp 9 hours ago ago

    Thanks! Pushed a refactor. Good catch.

  • zahlman 10 hours ago ago

            if self.moving_backwards:
                self.body.reverse()
                # Also reverse the direction vector
                self.direction = (-self.direction[0], -self.direction[1])
            else:
                # When switching back to forwards, reverse again to restore original orientation
                self.body.reverse()
                # Restore direction
                self.direction = (-self.direction[0], -self.direction[1])
    
    I don't think I need to explain the potential refactoring.