mirror of
https://github.com/kristoferssolo/School.git
synced 2025-10-21 20:10:38 +00:00
fix global variables
This commit is contained in:
parent
35c8a9a8aa
commit
fc80ab7ec5
@ -90,9 +90,9 @@ class Snake:
|
|||||||
if index == len(self.body) - 1:
|
if index == len(self.body) - 1:
|
||||||
self.turns.pop(head_pos)
|
self.turns.pop(head_pos)
|
||||||
else:
|
else:
|
||||||
from assets.scripts.menu import walls
|
from globals import walls
|
||||||
|
from snake import end_screen
|
||||||
if walls: # end game if goes into the wall
|
if walls: # end game if goes into the wall
|
||||||
from snake import end_screen
|
|
||||||
head.move(head.direction)
|
head.move(head.direction)
|
||||||
if head.direction[0] == -1 and head.pos[0] < 0: # left to right
|
if head.direction[0] == -1 and head.pos[0] < 0: # left to right
|
||||||
end_screen()
|
end_screen()
|
||||||
|
|||||||
@ -73,6 +73,9 @@ def options() -> None:
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
quit()
|
quit()
|
||||||
|
if event.type == pygame.KEYDOWN:
|
||||||
|
if event.key == pygame.K_ESCAPE:
|
||||||
|
main_menu()
|
||||||
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
|
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
|
||||||
if speed_button.check_input(mouse_pos):
|
if speed_button.check_input(mouse_pos):
|
||||||
change_speed()
|
change_speed()
|
||||||
@ -101,6 +104,9 @@ def scoreboard() -> None:
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
quit()
|
quit()
|
||||||
|
if event.type == pygame.KEYDOWN:
|
||||||
|
if event.key == pygame.K_ESCAPE:
|
||||||
|
main_menu()
|
||||||
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
|
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
|
||||||
if back_button.check_input(mouse_pos):
|
if back_button.check_input(mouse_pos):
|
||||||
main_menu()
|
main_menu()
|
||||||
|
|||||||
@ -47,6 +47,7 @@ def end_screen() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
snakes.clear()
|
||||||
from globals import fps, multiplayer, walls
|
from globals import fps, multiplayer, walls
|
||||||
pygame.display.set_caption("Snake")
|
pygame.display.set_caption("Snake")
|
||||||
|
|
||||||
@ -83,6 +84,9 @@ def main() -> None:
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
quit()
|
quit()
|
||||||
|
if event.type == pygame.KEYDOWN:
|
||||||
|
if event.key == pygame.K_ESCAPE:
|
||||||
|
end_screen()
|
||||||
|
|
||||||
for snake in snakes:
|
for snake in snakes:
|
||||||
snake.move()
|
snake.move()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user