summaryrefslogtreecommitdiffstats
path: root/main.py
blob: 7f31a294e8ccd8772803af416779a311a89b901d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from game import Game
from game_over import GameOver
from help import Help
from menu import Menu
from setup import *

is_running = True
delta = 0
clock = pygame.time.Clock()
screen = pygame.display.set_mode(dimensions)
scene = Menu()

while is_running:

    status = scene.update(delta)
    if status == COMMAND_EXIT:
        is_running = False
    elif status == COMMAND_LOSE:
        scene = GameOver(len(scene.snake.body), win=False)
    elif status == COMMAND_WIN:
        scene.draw(screen)
        scene = GameOver(len(scene.snake.body), win=True)
    elif status == COMMAND_START:
        scene = Game()
    elif status == COMMAND_HELP:
        scene = Help()
    elif status == COMMAND_MENU:
        scene = Menu()

    scene.draw(screen)

    pygame.display.flip()
    delta = clock.tick(60)

pygame.quit()