Return to repo list

gatemender

Arcade game about fixing warp gates. LibreJam Dec 2020 Entry.
Return to HMagellan.com

commit f0dc85bfcd3026d55a2cc0f3042055299ef3af28
parent 2fe20f281828514b42c1a296c6727adb3dd43ce5
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon,  7 Dec 2020 09:01:45 -0600

Added game mode prototype

Diffstat:
Msrc/constants.py | 1+
Msrc/game.py | 22+++++++++++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/constants.py b/src/constants.py @@ -41,3 +41,4 @@ SHOOT_KEY = pygame.K_SPACE THRUST_KEY = pygame.K_w REPAIR_KEY = pygame.K_e MATERIALS = enum.Enum("MATERIALS", "Alpha Beta Gamma") +MODES = enum.Enum("MODES", "Menu Transition GameOver Play") diff --git a/src/game.py b/src/game.py @@ -13,6 +13,7 @@ class Game(object): self.camera_surface_rect.topleft = (0, 0) self.frameclock = pygame.time.Clock() self.font = pygame.font.Font(FONTPATH, 24) + self.mode = MODES.Play # Loading self.images = { i : pygame.image.load(IMAGE_FILES[i]).convert() for i in IMAGE_FILES } @@ -27,6 +28,18 @@ class Game(object): # Others self.level_factor = 1 self.asteroid_spawn_timer = 100 + self.gate_defs = [] + + self.change_mode(MODES.Play) + + def load_level(self): + + # First, restore to default + self.screen_draw_group = pygame.sprite.Group() + self.camera_draw_group = pygame.sprite.Group() + self.asteroids = pygame.sprite.Group() + self.bullets = pygame.sprite.Group() + self.asteroid_spawn_timer = 100 self.gate_defs = [ [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 0, (416, 200) ], [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 0, (480, 200) ], @@ -38,9 +51,7 @@ class Game(object): [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 90, (416, 264) ], ] - self.load_level() - - def load_level(self): + # Next, load level broke = min(self.level_factor + 2, 5) bc = 0 for i in self.gate_defs: @@ -75,6 +86,11 @@ class Game(object): self.tray = sprites.CustomSprite(self, self.images["UI_Tray"], (self.screen_rect.centerx, 700)) self.screen_draw_group.add(self.tray) + def change_mode(self, mode): + self.mode = mode + if mode == MODES.Play: + self.load_level() + def shift_frames(self): self.frameclock.tick(FRAMERATE)