-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
60 lines (50 loc) · 2.03 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
57
58
59
60
import pygame, sys
from settings import *
from menu import Menu
from level import Level
from end_screen import End
class Game:
def __init__(self):
self.menu_is_present = True
pygame.init()
self.resolution = (WIDTH, HEIGHT) # rozdzielczosc do zmiany, pozniej wypelniana z ustawien (settings.py)
self.screen = pygame.display.set_mode(self.resolution, MODE_TYPES[2])
pygame.display.set_caption('Projekt Rogal') # nazwa do zmiany
self.clock = pygame.time.Clock()
self.end=End(self)
self.menu = Menu()
self.menu.give_board_size(*self.resolution) # screen params
self.menu.set_positions(self.screen)
self.level=Level(self)
def hide_menu(self):
self.menu_is_present = False
def run(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if self.menu_is_present:
self.menu.run(self)
elif self.level.is_running:
self.screen.fill('black')
self.level.run()
else:
font_size = 40
start_font = pygame.font.Font(None, font_size)
if self.level.win:
start_surface = start_font.render("The End!!!", False, MENU_FONT_SIZE)
self.screen.fill((94, 129, 162))
else:
start_surface = start_font.render("YOU'R DEAD", False, MENU_FONT_SIZE)
self.screen.fill('black')
score_message_rect = start_surface.get_rect(center=(WIDTH / 2, HEIGHT / 2))
self.screen.blit(start_surface, score_message_rect)
keys = pygame.key.get_pressed()
if keys [pygame.K_SPACE]:
exit()
pygame.display.update()
self.clock.tick(FPS) # to sa FPS, do ustawienia pozniej z (settings.py)
if __name__ == '__main__':
game = Game()
game.run()