Skip to content

Commit

Permalink
Merge pull request #74 from FrameworkComputer/fix-snake
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnAZoidberg authored Sep 7, 2023
2 parents 0520b39 + 1c16f74 commit 7698eef
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ledmatrix_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,15 +800,15 @@ def snake_embedded_keyscan():
send_command(dev, CommandVals.GameControl, [key_arg])


def game_over():
def game_over(dev):
global body
while True:
show_string('GAME ')
show_string(dev, 'GAME ')
time.sleep(0.75)
show_string('OVER!')
show_string(dev, 'OVER!')
time.sleep(0.75)
score = len(body)
show_string(f'{score:>3} P')
show_string(dev, f'{score:>3} P')
time.sleep(0.75)


Expand Down Expand Up @@ -850,7 +850,7 @@ def snake_embedded():
snake_embedded_keyscan()


def snake():
def snake(dev):
from getkey import keys
global direction
global body
Expand Down Expand Up @@ -892,7 +892,7 @@ def snake():
# Detect edge condition
(x, y) = head
if head in body:
return game_over()
return game_over(dev)
elif x >= WIDTH or x < 0 or y >= HEIGHT or y < 0:
if WRAP:
if x >= WIDTH:
Expand All @@ -905,7 +905,7 @@ def snake():
y = HEIGHT-1
head = (x, y)
else:
return game_over()
return game_over(dev)
elif head == food:
body.insert(0, oldhead)
while food == head:
Expand All @@ -922,7 +922,7 @@ def snake():
for bodypart in body:
(x, y) = bodypart
matrix[x][y] = 1
render_matrix(matrix)
render_matrix(dev, matrix)


def wpm_demo():
Expand All @@ -944,7 +944,7 @@ def wpm_demo():
if total_time < 10:
wpm = wpm / (total_time / 10)

show_string(' ' + str(int(wpm)))
show_string(dev, ' ' + str(int(wpm)))


def random_eq(dev):
Expand Down

0 comments on commit 7698eef

Please sign in to comment.