Skip to content

Instantly share code, notes, and snippets.

@cgawron
Created October 5, 2023 10:08
Show Gist options
  • Save cgawron/07cad639db0444db74f8864e81a2a9da to your computer and use it in GitHub Desktop.
Save cgawron/07cad639db0444db74f8864e81a2a9da to your computer and use it in GitHub Desktop.
# goes through right boundary
if self.head.x > self.w - BLOCK_SIZE:
self.head = Point(0, self.head.y)
# goes through left boundary
elif self.head.x < 0:
self.head = Point(self.w - BLOCK_SIZE, self.head.y)
# goes through bottom boundary
elif self.head.y > self.h - BLOCK_SIZE:
self.head = Point(self.head.x, 0)
# goes through top boundary
elif self.head.y < 0:
self.head = Point(self.head.x, self.h - BLOCK_SIZE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment