pneuma-pygame/game.py

53 lines
1.2 KiB
Python
Raw Normal View History

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-23 15:37:02 +00:00
(WIDTH, HEIGHT), pygame.HIDDEN)
2023-11-19 03:27:47 +00:00
pygame.display.set_caption('Pneuma')
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)
def calc_score(self):
2023-11-23 15:37:02 +00:00
self.scores = [0 for _ in range(self.max_num_players)]
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:
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()
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)
def quit(self):
pygame.quit()
sys.exit()