-
Notifications
You must be signed in to change notification settings - Fork 0
/
Asteroids.py
43 lines (36 loc) · 1.39 KB
/
Asteroids.py
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
36
37
38
39
40
41
42
43
import pygame
from Scripts.game import Game
from Scripts.menu import Menu
from Scripts.game_over_menu import Game_Over_Menu
def run():
"""Создание лаунчера игры"""
pygame.init()
pygame.mixer.pre_init(44100, -16, 1, 512)
pygame.mixer.music.load("sounds/background_music.mp3")
screen = pygame.display.set_mode((1600, 900))
pygame.display.set_caption("Asteroids")
menu = Menu(screen)
game = None
game_over = None
pygame.mixer.music.play(-1)
while True:
if menu.IsActive:
menu.update()
else:
if game is None and game_over is None:
game = Game(screen, menu.player_name)
if game is not None and not game.game_over:
game.game_update()
elif game is not None and game.game_over:
game.stat.update_high_score()
game_over = Game_Over_Menu(menu, screen,
game.stat.score,
menu.player_name,
game.stat.high_name,
game.stat.high_score)
game = None
elif game_over is not None and game_over.IsActive:
game_over.update()
if game_over is not None and not game_over.IsActive:
game_over = None
run()