Compare commits

...

5 Commits

Author SHA1 Message Date
4d32ff6f5a Added pishock to requirements 2025-07-16 12:07:07 +01:00
dee653ca31 Updated to use new internal parts of GameUtils 2025-06-24 14:36:43 +01:00
32aa61533c Linted code 2025-06-24 08:01:53 +01:00
214edfbe3a Updated to use GameUtils internal calls 2025-06-24 08:01:48 +01:00
1b84249f47 Removed redundant variable 2025-06-24 08:01:17 +01:00
2 changed files with 13 additions and 14 deletions

View File

@ -53,8 +53,6 @@ for path in os.listdir('../'):
log.debug(f'Loaded game {gameID}')
run = True
pygame.init()
# I'm sorry, I prefer object-oriented programming. So sue me.
@ -78,18 +76,18 @@ class Launcher:
os.chdir(game.path)
# Load the games game.py file.
spec = importlib.util.spec_from_file_location(game.id, os.path.join(game.path, 'game.py'))
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
# Initialise the games Game class, then set the
# current game to that.
self.currentGame = foo.Game(self.gameSurface)
self.currentGame = module.Game(self.gameSurface)
# Set the window title to the games name
pygame.display.set_caption(game.name)
def update(self):
for event in pygame.event.get():
if self.gameRunning:
self.currentGame.onEvent(event)
self.currentGame._onEvent(event)
# CTRL+ESC
if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE and event.mod == 64):
@ -100,7 +98,7 @@ class Launcher:
os.chdir(originalCWD)
pygame.display.set_caption('Pain Jam Launcher')
# If we launched directly into a game
if args.gameID != None:
if args.gameID is not None:
# Exit the launcher when we exit the game
self.running = False
else:
@ -112,8 +110,8 @@ class Launcher:
self.loadGame(games['russianRoulette'])
if self.gameRunning:
self.currentGame.update()
self.screen.blit(self.currentGame.surf, (0, 0))
self.currentGame._update()
self.screen.blit(self.currentGame._surf, (0, 0))
else:
self.screen.fill((0, 0, 0))
@ -123,10 +121,10 @@ class Launcher:
@property
def gameRunning(self):
return self.currentGame != None
return self.currentGame is not None
launcher = Launcher()
if args.gameID != None:
if args.gameID is not None:
launcher.loadGame(games[args.gameID])
while launcher.running:
launcher.update()

View File

@ -1,2 +1,3 @@
pygame-ce
pishock
attrs