2023-11-19 03:27:47 +00:00
|
|
|
import pygame
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from level.level import Level
|
|
|
|
from configs.system.window_config import WIDTH, HEIGHT, WATER_COLOR, FPS
|
|
|
|
|
|
|
|
|
|
|
|
class Game:
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
pygame.init()
|
|
|
|
|
|
|
|
self.screen = pygame.display.set_mode(
|
2023-11-24 13:55:04 +00:00
|
|
|
(WIDTH, HEIGHT)) # , pygame.HIDDEN)
|
2023-11-23 11:44:23 +00:00
|
|
|
|
2023-11-19 03:27:47 +00:00
|
|
|
pygame.display.set_caption('Pneuma')
|
2023-11-23 11:44:23 +00:00
|
|
|
|
|
|
|
img = pygame.image.load('assets/graphics/icon.png')
|
|
|
|
pygame.display.set_icon(img)
|
2023-11-19 03:27:47 +00:00
|
|
|
self.clock = pygame.time.Clock()
|
|
|
|
|
|
|
|
self.level = Level()
|
|
|
|
|
2023-11-23 15:37:02 +00:00
|
|
|
self.max_num_players = len(self.level.player_sprites)
|
|
|
|
|
2023-11-23 11:44:23 +00:00
|
|
|
def calc_score(self):
|
2023-11-23 15:37:02 +00:00
|
|
|
|
|
|
|
self.scores = [0 for _ in range(self.max_num_players)]
|
2023-11-23 11:44:23 +00:00
|
|
|
|
|
|
|
for player in self.level.player_sprites:
|
|
|
|
self.scores[player.player_id] = player.stats.exp
|
|
|
|
|
2023-11-19 03:27:47 +00:00
|
|
|
def run(self):
|
|
|
|
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
2023-11-23 11:44:23 +00:00
|
|
|
self.quit()
|
2023-11-19 03:27:47 +00:00
|
|
|
if event.type == pygame.KEYDOWN:
|
|
|
|
if event.key == pygame.K_m:
|
|
|
|
self.level.toggle_menu()
|
2023-11-24 23:26:47 +00:00
|
|
|
self.level.observer.update()
|
2023-11-19 03:27:47 +00:00
|
|
|
|
|
|
|
self.screen.fill(WATER_COLOR)
|
|
|
|
|
2023-11-23 15:37:02 +00:00
|
|
|
self.level.run()
|
2023-11-19 03:27:47 +00:00
|
|
|
|
|
|
|
pygame.display.update()
|
|
|
|
self.clock.tick(FPS)
|
2023-11-23 11:44:23 +00:00
|
|
|
|
|
|
|
def quit(self):
|
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|