-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (33 loc) · 1.15 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
import pygame, sys
from settings import *
from level import Level
# from debug import debug
class Game:
def __init__(self):
# general setup
pygame.init()
self.screen = pygame.display.set_mode((WIDTH, HEIGTH))
pygame.display.set_caption('The Legend Of Hero')
self.clock = pygame.time.Clock()
self.level = Level()
# sound
main_sound = pygame.mixer.Sound('./audio/main.ogg')
main_sound.set_volume(0.5)
main_sound.play(loops = -1) # play continuosly
def run(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_m:
self.level.toggle_menu()
self.screen.fill(WATER_COLOR) # fills the area outside of the island with water color
self.level.run()
# debug('hello :)')
pygame.display.update()
self.clock.tick(FPS)
if __name__ == '__main__':
game = Game()
game.run()