Return to repo list

gatemender

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

commit da25bce7fe4a4cfb95cd94e4193ae04145142b08
parent 707147ae24f199d88aa2e3b33c4543ef8c4952e7
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon,  7 Dec 2020 08:01:01 -0600

Added damage to ship

Diffstat:
Msrc/sprites.py | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/sprites.py b/src/sprites.py @@ -60,6 +60,10 @@ class Ship(CustomSprite): self.fixing = False # Other + self.hp = 3 + self.blinking = False + self.blinking_timer_max = 120 + self.blinking_timer = self.blinking_timer_max self.aura = FixAura(self.manager, self.manager.images["Fix_Aura"], self.rect.center, 0, self) self.manager.camera_draw_group.add(self.aura) @@ -125,6 +129,28 @@ class Ship(CustomSprite): y = self.manager.camera_surface_rect.height + (self.rect.height / 2) self.rect.center = (x, y) self.position = pygame.Vector2(self.rect.center) + + + # Damage blink and asteroid col + if self.blinking: + if (self.blinking_timer // 10) % 2 != 0: + self.visible = False + else: + self.visible = True + if self.blinking_timer > 0: + self.blinking_timer -= 1 + else: + self.blinking = False + self.blinking_timer = self.blinking_timer_max + else: + for s in self.manager.asteroids.sprites(): + if self.rect.colliderect(s.rect): + s.destroy() + self.hp -= 1 + if self.hp > 0: + self.blinking = True + else: + self.manager.on = False #TMP, obv # Bullet class class Bullet(CustomSprite):