pneuma-pygame/game.py

63 lines
1.4 KiB
Python
Raw Normal View History

2024-02-10 17:11:28 +00:00
import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
from config.system.window import WIDTH,\
HEIGHT,\
WATER_COLOR,\
FPS
from level import Level
import pygame
import sys
2023-11-19 03:27:47 +00:00
2024-02-10 17:11:28 +00:00
class Pneuma:
2023-11-19 03:27:47 +00:00
def __init__(self, show_pg=False, n_players=1,):
print(f"Initializing Pneuma with {n_players} player(s).\
\nShowing PyGame screen: {'True' if show_pg else 'False'}")
2023-11-19 03:27:47 +00:00
pygame.init()
if show_pg:
2023-11-19 03:27:47 +00:00
self.screen = pygame.display.set_mode(
(WIDTH, HEIGHT)
)
2023-11-19 03:27:47 +00:00
else:
self.screen = pygame.display.set_mode(
(WIDTH, HEIGHT),
pygame.HIDDEN
)
2023-11-23 15:37:02 +00:00
pygame.display.set_caption("Pneuma")
2023-11-23 15:37:02 +00:00
img = pygame.image.load(os.path.join('assets',
'graphics',
'icon.png'))
pygame.display.set_icon(img)
self.level = Level(n_players)
2023-11-19 03:27:47 +00:00
def run(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.quit()
elif event.type == pygame.KEYDOWN:
2023-11-19 03:27:47 +00:00
if event.key == pygame.K_m:
self.level.pause()
2023-11-19 03:27:47 +00:00
self.screen.fill(WATER_COLOR)
self.level.run()
2023-11-19 03:27:47 +00:00
pygame.display.update()
def quit(self):
pygame.quit()
sys.exit()