Return to repo list

gatemender

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

commit 6b7cb94403b4c17d4d4d817bc0517d6563c954de
parent 30617441378ea023e57ff5bf4b8c3078c9c16867
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun,  6 Dec 2020 19:08:11 -0600

more imgs and work on asteroid collision

Diffstat:
Adata/alpha_halo_angle.png | 0
Adata/alpha_halo_straight.png | 0
Adata/beta_halo_angle.png | 0
Adata/beta_halo_straight.png | 0
Adata/gamma_halo_angle.png | 0
Adata/gamma_halo_straight.png | 0
Mdata/gate_angle_broken.png | 0
Mdata/gate_angle_fixed.png | 0
Mdata/gate_straight_broken.png | 0
Mdata/gate_straight_fixed.png | 0
Adata/hud_tray.png | 0
Msrc/game.py | 6+++++-
Msrc/sprites.py | 9++++++++-
13 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/data/alpha_halo_angle.png b/data/alpha_halo_angle.png Binary files differ. diff --git a/data/alpha_halo_straight.png b/data/alpha_halo_straight.png Binary files differ. diff --git a/data/beta_halo_angle.png b/data/beta_halo_angle.png Binary files differ. diff --git a/data/beta_halo_straight.png b/data/beta_halo_straight.png Binary files differ. diff --git a/data/gamma_halo_angle.png b/data/gamma_halo_angle.png Binary files differ. diff --git a/data/gamma_halo_straight.png b/data/gamma_halo_straight.png Binary files differ. diff --git a/data/gate_angle_broken.png b/data/gate_angle_broken.png Binary files differ. diff --git a/data/gate_angle_fixed.png b/data/gate_angle_fixed.png Binary files differ. diff --git a/data/gate_straight_broken.png b/data/gate_straight_broken.png Binary files differ. diff --git a/data/gate_straight_fixed.png b/data/gate_straight_fixed.png Binary files differ. diff --git a/data/hud_tray.png b/data/hud_tray.png Binary files differ. diff --git a/src/game.py b/src/game.py @@ -16,6 +16,8 @@ class Game(object): # Game objects self.drawables = pygame.sprite.Group() + self.asteroids = pygame.sprite.Group() + self.bullets = pygame.sprite.Group() self.ship = sprites.Ship(self, self.images["Ship"], self.screen.get_rect().center) self.drawables.add(self.ship) @@ -93,7 +95,9 @@ class Game(object): else: im = self.images["Big_Asteroid"] spawnpos = (random.randint(0, SCREEN_DIM[1]), -65) - self.drawables.add(sprites.Asteroid(self, im, spawnpos, 270, size)) + a = sprites.Asteroid(self, im, spawnpos, 270, size) + self.drawables.add(a) + self.asteroids.add(a) self.asteroid_spawn_timer = 10 * (10 / self.level_factor) else: self.asteroid_spawn_timer -= 1 diff --git a/src/sprites.py b/src/sprites.py @@ -70,7 +70,9 @@ class Ship(CustomSprite): self.rotate(self.angle + amount) def shoot(self): - self.manager.drawables.add(Bullet(self.manager, self.manager.images["Bullet"], self.rect.center, self.angle)) + b = Bullet(self.manager, self.manager.images["Bullet"], self.rect.center, self.angle) + self.manager.drawables.add(b) + self.manager.bullets.add(b) def act(self): @@ -121,7 +123,12 @@ class Asteroid(CustomSprite): self.size = size # 0 = small; 1 = medium; 2 = large self.spin_speed = random.randint(-7, 7) self.speed = random.randint(1, manager.level_factor + 1) + self.entered_screen = False def act(self): self.offset_move((0, self.speed)) self.rotate(self.angle + self.spin_speed) + if self.rect.colliderect(self.manager.screen_rect): + self.entered_screen = True + elif self.entered_screen == True: + self.kill()