Created
October 5, 2023 10:48
-
-
Save cgawron/6c3e0f28c80fde0cb18687722f2c8a3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WHITE = (255, 255, 255) # Python's color code for white | |
EYE_WIDTH = 3 | |
EYE_HEIGHT = 3 | |
def draw_snake_eyes(self, direction): | |
pt = self.snake[0] | |
if direction == 'UP': | |
eye_pos1 = (pt.x + 5, pt.y + 5) | |
eye_pos2 = (pt.x + BLOCK_SIZE - 10, pt.y + 5) | |
elif direction == 'DOWN': | |
eye_pos1 = (pt.x + 5, pt.y + BLOCK_SIZE - 10) | |
eye_pos2 = (pt.x + BLOCK_SIZE - 10, pt.y + BLOCK_SIZE - 10) | |
elif direction == 'LEFT': | |
eye_pos1 = (pt.x + 5, pt.y + 5) | |
eye_pos2 = (pt.x + 5, pt.y + BLOCK_SIZE - 10) | |
elif direction == 'RIGHT': | |
eye_pos1 = (pt.x + BLOCK_SIZE - 10, pt.y + 5) | |
eye_pos2 = (pt.x + BLOCK_SIZE - 10, pt.y + BLOCK_SIZE - 10) | |
# Draw eyes | |
pygame.draw.rect(self.display, WHITE, pygame.Rect(*eye_pos1, EYE_WIDTH, EYE_HEIGHT)) | |
pygame.draw.rect(self.display, WHITE, pygame.Rect(*eye_pos2, EYE_WIDTH, EYE_HEIGHT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment