-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (39 loc) · 1.32 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
import pygame
from pygame.mixer import find_channel
from Tools import terminate
from Tools.Image import load_image
from PyGame_Additions import SingleSprite
from GUI_Stages.game_interface import GameInterface
from Game_Parts import GameBoard
from constants import SCREEN_SIZE
from game_events import PLAY_SCORE_SOUND
RUNNING = True
pygame.init()
SCREEN = pygame.display.set_mode(SCREEN_SIZE)
pygame.display.set_icon(load_image("icon.png", -1))
pygame.display.set_caption("Python Tetris v2.0")
CLOCK = pygame.time.Clock()
FRAMERATE_LOCK = 60
FON = SingleSprite("background.png")
pygame.mixer.music.load('data/music/main_theme.ogg')
pygame.mixer.music.play(-1)
SCORE_SOUND = pygame.mixer.Sound('data/music/deleting_line_sound.wav')
SCORE_SOUND.set_volume(0.4)
INTERFACE = GameInterface()
GAME = GameBoard()
while RUNNING:
FON.draw(SCREEN)
INTERFACE.update_without_event(CLOCK)
GAME.update_without_event(pygame, pygame.time.get_ticks())
for event in pygame.event.get():
if event.type == pygame.QUIT:
terminate()
if event.type == PLAY_SCORE_SOUND:
channel = find_channel(True)
channel.play(SCORE_SOUND)
INTERFACE.update(pygame, event)
GAME.update(pygame, event)
GAME.draw(SCREEN)
INTERFACE.draw(SCREEN)
CLOCK.tick(60)
pygame.display.flip()