wasd
This commit is contained in:
parent
fa0e8614db
commit
cf1dcee5a5
1 changed files with 7 additions and 7 deletions
14
snek.py
14
snek.py
|
@ -18,7 +18,7 @@ class Snek():
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.direction = point
|
self.direction = point
|
||||||
|
|
||||||
def move(self):
|
def move(self):
|
||||||
cur = self.get_head_position()
|
cur = self.get_head_position()
|
||||||
x, y = self.direction
|
x, y = self.direction
|
||||||
|
@ -50,13 +50,13 @@ class Snek():
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif event.type == pygame.KEYDOWN:
|
elif event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_UP:
|
if event.key == pygame.K_UP or event.key == pygame.K_w:
|
||||||
self.turn(UP) # all da way
|
self.turn(UP) # all da way
|
||||||
elif event.key == pygame.K_DOWN:
|
elif event.key == pygame.K_DOWN or event.key == pygame.K_s:
|
||||||
self.turn(DOWN) # for what?
|
self.turn(DOWN) # for what?
|
||||||
elif event.key == pygame.K_LEFT:
|
elif event.key == pygame.K_LEFT or event.key == pygame.K_a:
|
||||||
self.turn(LEFT)
|
self.turn(LEFT)
|
||||||
elif event.key == pygame.K_RIGHT:
|
elif event.key == pygame.K_RIGHT or event.key == pygame.K_d:
|
||||||
self.turn(RIGHT)
|
self.turn(RIGHT)
|
||||||
|
|
||||||
class Food():
|
class Food():
|
||||||
|
@ -111,7 +111,7 @@ def main():
|
||||||
|
|
||||||
snek = Snek()
|
snek = Snek()
|
||||||
food = Food()
|
food = Food()
|
||||||
|
|
||||||
fontSize = 18
|
fontSize = 18
|
||||||
scoreFont = pygame.font.SysFont("monospace", fontSize)
|
scoreFont = pygame.font.SysFont("monospace", fontSize)
|
||||||
scoreColor = (255, 255, 255)
|
scoreColor = (255, 255, 255)
|
||||||
|
@ -141,4 +141,4 @@ def main():
|
||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue