Return to repo list

gatemender

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

commit 521bd3211315b2de25039198ab1685e6f567a79c
parent a608bcd980b68c10de66f01838f0e35181c8d9da
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Tue, 15 Dec 2020 16:12:17 -0600

Added hp pickup and improved vortex graphic

Diffstat:
Adata/fire.png | 0
Adata/repair_pickup.png | 0
Mdata/vortex.png | 0
Msrc/constants.py | 1+
Msrc/sprites.py | 38+++++++++++++++++++++++++++++++++-----
5 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/data/fire.png b/data/fire.png Binary files differ. diff --git a/data/repair_pickup.png b/data/repair_pickup.png Binary files differ. diff --git a/data/vortex.png b/data/vortex.png Binary files differ. diff --git a/src/constants.py b/src/constants.py @@ -57,6 +57,7 @@ IMAGE_FILES = { "Big_Alpha_Icon" : os.path.join("data", "alpha_material_big.png"), "Big_Beta_Icon" : os.path.join("data", "beta_material_big.png"), "Big_Gamma_Icon" : os.path.join("data", "gamma_material_big.png"), + "Repair_Pickup" : os.path.join("data", "repair_pickup.png"), "UI_Tray" : os.path.join("data", "hud_tray.png"), "Fix_Aura" : os.path.join("data", "fix_aura.png"), "Vortex" : os.path.join("data", "vortex.png"), diff --git a/src/sprites.py b/src/sprites.py @@ -73,7 +73,7 @@ class Ship(CustomSprite): self.burst_delay = 2 + self.manager.level_factor def thrust(self): - self.manager.play_sound("Thrust", 3, False, 0, False) + self.manager.play_sound("Thrust", 2, False, 0, False) if self.speed < SHIP_MAX_SPEED: self.speed += self.thrust_factor @@ -287,7 +287,7 @@ class Asteroid(CustomSprite): self.spin_speed = random.randint(-7, 7) self.speed = random.randint(1, manager.level_factor + 1) self.entered_screen = False - self.contents = random.randint(0, 9) + self.contents = random.randint(0, 18) def be_damaged(self): self.hp -= 1 @@ -298,21 +298,26 @@ class Asteroid(CustomSprite): self.manager.score += 10 * self.manager.level_factor def spawn_pickup(self): - if self.contents == 0: + if self.contents in (0, 1): 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: + elif self.contents in (2, 3): 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: + elif self.contents in (4, 5): 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) + elif self.contents == 17: + p = RepairPickup(self.manager, self.manager.images["Repair_Pickup"], self.rect.center, 0) + 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 @@ -378,6 +383,29 @@ class Pickup(CustomSprite): self.manager.ship.materials[self.material] += 1 self.kill() +class RepairPickup(CustomSprite): + + def __init__(self, manager, image, pos, angle = 0): + super().__init__(manager, image, pos, angle) + self.lifetime = 1000 // max(1, self.manager.level_factor // 2) + + def act(self): + self.rotate(self.angle + 1) + if self.lifetime > 0: + self.lifetime -= 1 + if self.lifetime < 180: + if self.lifetime % 2 == 0 or self.lifetime % 3 == 0: + self.visible = False + else: + self.visible = True + else: + self.kill() + if self.rect.colliderect(self.manager.ship.rect): + self.manager.play_sound("Pickup", 3, True, 0, False) + if self.manager.ship.hp < 3: + self.manager.ship.hp += 1 + self.kill() + class Vortex(CustomSprite): def __init__(self, manager, image, pos, angle = 0):