Skip to content

Commit a7ee1f3

Browse files
Merge pull request steam-bell-92#1372 from jatingow/fix/snake-game-unbound-local-error
fix: add global declaration in game_loop() to resolve UnboundLocalError
2 parents 04cc854 + edda50b commit a7ee1f3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

games/Snake-Game/Snake-Game.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def move():
233233
game_text.write("Press SPACEBAR to Start", align="center", font=("Arial", 24, "bold"))
234234

235235
def game_loop():
236+
global game_state, score, high_score, level, speed
236237
screen.update()
237238

238239
if game_state in ["IDLE", "PAUSED", "GAME_OVER"]:
@@ -307,6 +308,7 @@ def game_loop():
307308
screen.ontimer(game_loop, int(speed * 1000))
308309

309310
screen.ontimer(game_loop, 100)
311+
screen.mainloop()
310312

311313
if __name__ == '__main__':
312314
main()

0 commit comments

Comments
 (0)