2024-02-10 17:11:28 +00:00
|
|
|
import os
|
|
|
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
|
|
|
|
|
|
from config.system.window import WIDTH,\
|
2023-11-29 10:53:30 +00:00
|
|
|
HEIGHT,\
|
|
|
|
WATER_COLOR,\
|
|
|
|
FPS
|
2023-12-14 17:28:45 +00:00
|
|
|
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
|
|
|
|
2023-11-29 10:53:30 +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()
|
|
|
|
|
2023-11-29 10:53:30 +00:00
|
|
|
if show_pg:
|
2023-11-19 03:27:47 +00:00
|
|
|
|
2023-11-29 10:53:30 +00:00
|
|
|
self.screen = pygame.display.set_mode(
|
|
|
|
(WIDTH, HEIGHT)
|
|
|
|
)
|
2023-11-19 03:27:47 +00:00
|
|
|
|
2023-11-29 10:53:30 +00:00
|
|
|
else:
|
|
|
|
self.screen = pygame.display.set_mode(
|
|
|
|
(WIDTH, HEIGHT),
|
|
|
|
pygame.HIDDEN
|
|
|
|
)
|
2023-11-23 15:37:02 +00:00
|
|
|
|
2023-11-29 10:53:30 +00:00
|
|
|
pygame.display.set_caption("Pneuma")
|
2023-11-23 15:37:02 +00:00
|
|
|
|
2023-11-29 10:53:30 +00:00
|
|
|
img = pygame.image.load(os.path.join('assets',
|
|
|
|
'graphics',
|
|
|
|
'icon.png'))
|
|
|
|
pygame.display.set_icon(img)
|
2023-11-23 11:44:23 +00:00
|
|
|
|
2023-11-29 10:53:30 +00:00
|
|
|
self.level = Level(n_players)
|
2023-11-23 11:44:23 +00:00
|
|
|
|
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-29 10:53:30 +00:00
|
|
|
elif event.type == pygame.KEYDOWN:
|
2023-11-19 03:27:47 +00:00
|
|
|
if event.key == pygame.K_m:
|
2023-11-29 10:53:30 +00:00
|
|
|
self.level.pause()
|
2023-11-19 03:27:47 +00:00
|
|
|
|
|
|
|
self.screen.fill(WATER_COLOR)
|
|
|
|
|
2023-12-14 17:28:45 +00:00
|
|
|
self.level.run()
|
2023-11-19 03:27:47 +00:00
|
|
|
|
|
|
|
pygame.display.update()
|
2023-11-23 11:44:23 +00:00
|
|
|
|
|
|
|
def quit(self):
|
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|