Show HN: Reverse Snake (PyGame)

1 DavidCanHelp 2 8/3/2025, 3:41:59 PM github.com ↗

Comments (2)

DavidCanHelp · 2h ago
Thanks! Pushed a refactor. Good catch.
zahlman · 3h 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.