Skip to content

Commit

Permalink
Fixed line 64 TypeError: Iterating over key states is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
hmzq-dev authored Jun 12, 2023
1 parent b932713 commit 1c9f4d6
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,22 @@ def move(self):
pygame.quit()
keys = pygame.key.get_pressed()

for key in keys:
if keys[pygame.K_LEFT]:
self.dirnx = -1
self.dirny = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]
elif keys[pygame.K_RIGHT]:
self.dirnx = 1
self.dirny = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]
elif keys[pygame.K_UP]:
self.dirny = -1
self.dirnx = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]
elif keys[pygame.K_DOWN]:
self.dirny = 1
self.dirnx = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]
if keys[pygame.K_LEFT]:
self.dirnx = -1
self.dirny = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]
elif keys[pygame.K_RIGHT]:
self.dirnx = 1
self.dirny = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]
elif keys[pygame.K_UP]:
self.dirny = -1
self.dirnx = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]
elif keys[pygame.K_DOWN]:
self.dirny = 1
self.dirnx = 0
self.turns[self.head.pos[:]] = [self.dirnx,self.dirny]

for i, c in enumerate(self.body):
p = c.pos[:]
Expand Down

0 comments on commit 1c9f4d6

Please sign in to comment.