Return to repo list

gatemender

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

commit 1ad3789a206c4ad30b964b6fd55fc3cdea1d245d
parent fe93875bf1507de7090fe4339eff806460904170
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon,  7 Dec 2020 11:52:35 -0600

added burst

Diffstat:
Msrc/constants.py | 1+
Msrc/game.py | 21++++++++++++++++++++-
Msrc/sprites.py | 19+++++++++++++++++++
3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/src/constants.py b/src/constants.py @@ -43,5 +43,6 @@ BRAKE_KEY = pygame.K_s SHOOT_KEY = pygame.K_SPACE THRUST_KEY = pygame.K_w REPAIR_KEY = pygame.K_e +BURST_KEY = pygame.K_k 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 @@ -93,7 +93,7 @@ class Game(object): i[0] = False while bc < broke: ind = random.randint(0, 7) - if self.gate_defs[ind][0]: + if not self.gate_defs[ind][0]: self.gate_defs[ind][0] = True bc += 1 @@ -164,6 +164,21 @@ class Game(object): self.hp_meter_rect.center = (60, 720) self.hp_meter_fill_rect.bottom = self.hp_meter_rect.bottom - 1 self.hp_meter_fill_rect.centerx = self.hp_meter_rect.centerx + burst_fill_colo = (0, 0, 200) + if self.ship.burst_counter == 100: + burst_fill_colo = (255, 255, 255) + self.burst_heading = self.font.render("BURST", False, (0, 255, 255)) + self.burst_heading_rect = self.burst_heading.get_rect() + self.burst_heading_rect.center = (820, 720) + self.burst_meter = pygame.Surface((100, 32)) + self.burst_meter.fill((135, 0, 22)) + self.burst_meter_rect = self.burst_meter.get_rect() + self.burst_meter_fill = pygame.Surface((self.ship.burst_counter, 32)) + self.burst_meter_fill.fill(burst_fill_colo) + self.burst_meter_fill_rect = self.burst_meter_fill.get_rect() + self.burst_meter_rect.center = (816, 720) + self.burst_meter_fill_rect.bottom = self.burst_meter_rect.bottom - 1 + self.burst_meter_fill_rect.centerx = self.burst_meter_rect.centerx def shift_frames(self): self.frameclock.tick(FRAMERATE) @@ -189,6 +204,7 @@ class Game(object): self.ship.shooting = self.keys[SHOOT_KEY] self.ship.thrusting = self.keys[THRUST_KEY] self.ship.fixing = self.keys[REPAIR_KEY] + self.ship.bursting = self.keys[BURST_KEY] def update_screen(self): if self.mode == MODES.Play: @@ -206,6 +222,9 @@ class Game(object): self.screen.blit(self.hp_meter, self.hp_meter_rect) self.screen.blit(self.hp_meter_fill, self.hp_meter_fill_rect) self.screen.blit(self.hp_heading, self.hp_heading_rect) + self.screen.blit(self.burst_meter, self.burst_meter_rect) + self.screen.blit(self.burst_meter_fill, self.burst_meter_fill_rect) + self.screen.blit(self.burst_heading, self.burst_heading_rect) elif self.mode == MODES.Transition: self.screen.fill((0, 0, 0)) self.screen.blit(self.lives_text, (100, 100)) diff --git a/src/sprites.py b/src/sprites.py @@ -59,6 +59,7 @@ class Ship(CustomSprite): self.turning_right = False self.fixing = False self.blinking = False + self.bursting = False self.dead = False # Other @@ -70,6 +71,8 @@ class Ship(CustomSprite): self.manager.camera_draw_group.add(self.aura) self.materials = { m : 5 for m in MATERIALS } self.be_dead_timer = 60 + self.burst_counter = 100 + self.burst_delay = 2 + self.manager.level_factor def thrust(self): if self.speed < SHIP_MAX_SPEED: @@ -87,6 +90,12 @@ class Ship(CustomSprite): b = Bullet(self.manager, self.manager.images["Bullet"], self.rect.center, self.angle) self.manager.camera_draw_group.add(b) self.manager.bullets.add(b) + + def burst(self): + for a in self.manager.asteroids: + a.destroy() + self.manager.asteroid_spawn_timer = 100 + self.burst_counter = 0 def act(self): @@ -148,6 +157,16 @@ class Ship(CustomSprite): self.rect.center = (x, y) self.position = pygame.Vector2(self.rect.center) + # Burst + if self.burst_counter < 100: + if self.burst_delay > 0: + self.burst_delay -= 1 + else: + self.burst_delay = 2 + self.manager.level_factor + self.burst_counter += 1 + elif self.bursting: + self.burst() + self.manager.camera_surface.fill((255, 255, 255)) # Damage blink and asteroid col if self.blinking: