Return to repo list

gatemender

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

commit a608bcd980b68c10de66f01838f0e35181c8d9da
parent e87b7cc4f287c8ebdadb0dafd842e9b4f03976f3
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Tue, 15 Dec 2020 00:16:44 -0600

Improved sfx and fixed gate respawn error

Diffstat:
Mhs.json | 4++--
Msrc/game.py | 34++++++++++++++++++----------------
Msrc/sprites.py | 12+++++++++---
3 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/hs.json b/hs.json @@ -1 +1 @@ -{"SCORES": [500, 1000]}- \ No newline at end of file +{"SCORES": [30, 280, 500, 1000]}+ \ No newline at end of file diff --git a/src/game.py b/src/game.py @@ -110,14 +110,14 @@ class Game(object): # Definitions self.gate_defs = [ - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 0, (416, 200), "Angle" ], - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 0, (480, 200), "Straight" ], - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 270, (544, 200), "Angle" ], - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 270, (544, 264), "Straight" ], - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 180, (544, 328), "Angle" ], - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 180, (480, 328), "Straight" ], - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 90, (416, 328), "Angle" ], - [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 90, (416, 264), "Straight" ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 0, (416, 200), "Angle", None ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 0, (480, 200), "Straight", None ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 270, (544, 200), "Angle", None ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 270, (544, 264), "Straight", None ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 180, (544, 328), "Angle", None ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 180, (480, 328), "Straight", None ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 90, (416, 328), "Angle", None ], + [ bool(random.getrandbits(1)), MATERIALS(random.randint(1, 3)), 90, (416, 264), "Straight", None ], ] self.gate_pieces = pygame.sprite.Group() @@ -137,7 +137,7 @@ class Game(object): bc += 1 else: self.preserve_gate = False - self.gate_defs = [ [ g.broken, g.requirement, g.angle, g.rect.center, g.or_name] for g in self.gate_pieces ] + self.gate_defs = [ [ g.broken, g.requirement, g.angle, g.rect.center, g.or_name, g.needed ] for g in self.gate_pieces ] self.gate_pieces = pygame.sprite.Group() x = 0 @@ -146,7 +146,7 @@ class Game(object): bstr = "Fixed" else: bstr = "Broken" - gp = sprites.GatePiece(self, self.images["Gate_" + n[4] + "_" + bstr], n[3], n[2], n[4], n[0], n[1]) + gp = sprites.GatePiece(self, self.images["Gate_" + n[4] + "_" + bstr], n[3], n[2], n[4], n[0], n[1], n[5]) self.gate_pieces.add(gp) self.camera_draw_group.add(gp) x += 1 @@ -184,6 +184,7 @@ class Game(object): self.lives = 2 self.score = 0 self.level_factor = 1 + self.preserve_gate = False elif mode == MODES.Options: self.music_on_checkbox = sprites.Checkbox(self, self.images["Checked_Checkbox"], (self.screen_rect.centerx + 140, self.screen_rect.centery - 32), 0, self.music_on) self.sound_on_checkbox = sprites.Checkbox(self, self.images["Checked_Checkbox"], (self.screen_rect.centerx + 140, self.screen_rect.centery + 32), 0, self.sound_on) @@ -384,12 +385,13 @@ class Game(object): self.asteroid_spawn_timer -= 1 def check_gate_complete(self): - for g in self.gate_pieces.sprites(): - if g.broken: - return - self.play_sound("Complete", 0, True, 0, False) - self.vortex.visible = True - self.vortex.passthru = True + if not self.vortex.visible: + for g in self.gate_pieces.sprites(): + if g.broken: + return + self.play_sound("Complete", 0, True, 0, False) + self.vortex.visible = True + self.vortex.passthru = True def increment_level(self): for m in self.ship.materials: diff --git a/src/sprites.py b/src/sprites.py @@ -92,6 +92,7 @@ class Ship(CustomSprite): self.manager.play_sound("Shoot", 1, True, 0, False) def burst(self): + self.manager.play_sound("Flash", 3, True, 0, False) for a in self.manager.asteroids: a.destroy() self.manager.asteroid_spawn_timer = 100 @@ -223,12 +224,12 @@ class Bullet(CustomSprite): # Gate components class GatePiece(CustomSprite): - def __init__(self, manager, image, pos, angle = 0, or_name = "Straight", broken = False, req = None): + def __init__(self, manager, image, pos, angle = 0, or_name = "Straight", broken = False, req = None, needed = None): super().__init__(manager, image, pos, angle) self.broken = broken self.requirement = req self.or_name = or_name - self.needed = 0 + self.needed = needed self.needed_text = None self.needed_text_rect = None self.halo_image = None @@ -237,7 +238,8 @@ class GatePiece(CustomSprite): self.halo_image = pygame.transform.rotate(self.manager.images[self.requirement.name + "_Halo_" + or_name], self.angle) self.halo_rect = self.halo_image.get_rect() self.halo_rect.center = self.rect.center - self.needed = random.randint(1, self.manager.level_factor) + if needed == None: + self.needed = random.randint(1, self.manager.level_factor) self.needed_text = self.manager.font.render(str(self.needed), False, (255, 255, 255)) self.needed_text_rect = self.needed_text.get_rect() self.needed_text_rect.center = self.rect.center @@ -300,14 +302,17 @@ class Asteroid(CustomSprite): p = Pickup(self.manager, self.manager.images["Alpha_Icon"], self.rect.center, 0, MATERIALS.Alpha) self.manager.pickups.add(p) self.manager.camera_draw_group.add(p) + self.manager.play_sound("Appear", 3, True, 0, False) elif self.contents == 1: p = Pickup(self.manager, self.manager.images["Beta_Icon"], self.rect.center, 0, MATERIALS.Beta) self.manager.pickups.add(p) self.manager.camera_draw_group.add(p) + self.manager.play_sound("Appear", 3, True, 0, False) elif self.contents == 2: p = Pickup(self.manager, self.manager.images["Gamma_Icon"], self.rect.center, 0, MATERIALS.Gamma) self.manager.pickups.add(p) self.manager.camera_draw_group.add(p) + self.manager.play_sound("Appear", 3, True, 0, False) def destroy(self): x = -1 @@ -369,6 +374,7 @@ class Pickup(CustomSprite): else: self.kill() if self.rect.colliderect(self.manager.ship.rect): + self.manager.play_sound("Pickup", 3, True, 0, False) self.manager.ship.materials[self.material] += 1 self.kill()