diff options
author | Viljami Ilola <+@hix.fi> | 2024-03-30 13:04:39 +0200 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-03-30 13:04:39 +0200 |
commit | acfac65f17a274d6d7f73cb44ed9476032241134 (patch) | |
tree | 0ef93c0d81171a6be751e3edd8d4a029f1095fcc /src/sliceitoff/game | |
parent | 607c00bc57fb68572754404cb5da0e7f7a5618e5 (diff) |
lint, refactor, doc, repeat
Diffstat (limited to 'src/sliceitoff/game')
-rw-r--r-- | src/sliceitoff/game/gameplay.py | 7 | ||||
-rw-r--r-- | src/sliceitoff/game/initials.py | 3 | ||||
-rw-r--r-- | src/sliceitoff/game/level.py | 10 | ||||
-rw-r--r-- | src/sliceitoff/game/show.py | 4 |
4 files changed, 10 insertions, 14 deletions
diff --git a/src/sliceitoff/game/gameplay.py b/src/sliceitoff/game/gameplay.py index ef708c4..5a14767 100644 --- a/src/sliceitoff/game/gameplay.py +++ b/src/sliceitoff/game/gameplay.py @@ -7,15 +7,13 @@ class Gameplay: self, player = None, field = None, - status = None, enemies = None, stats = None): - self.status = status self.player = player self.field = field self.enemies = enemies self.stats = stats - + def fire(self): """ Lazer is fired. Actions to be taken. """ zap_sprite = self.field.slice( @@ -33,9 +31,10 @@ class Gameplay: return self.stats.percent < 20 def quit(self): + """ Lose lives so no leveling up """ self.stats.lives = 0 return True - + def step(self): """ Processes events for the step (frame) """ for event in pygame.event.get(): diff --git a/src/sliceitoff/game/initials.py b/src/sliceitoff/game/initials.py index 49db3d6..7811afa 100644 --- a/src/sliceitoff/game/initials.py +++ b/src/sliceitoff/game/initials.py @@ -14,8 +14,9 @@ class Initials(pygame.sprite.Group): self.explode = False self.active = True self.fadeout = 1_000 - + def update(self, dt = 0, **kwargs): + """ Does it all. Reads keyboard and updates screen """ if not self.active: return diff --git a/src/sliceitoff/game/level.py b/src/sliceitoff/game/level.py index 26df345..0742213 100644 --- a/src/sliceitoff/game/level.py +++ b/src/sliceitoff/game/level.py @@ -20,7 +20,6 @@ class Level: self.field = Field(stats = self.stats) self.enemies = Enemies(count = self.stats.enemies) self.player = Player() - self.player_single = pygame.sprite.Group() self.level_info = Show(level_screen(stats.level)) self.ended = False @@ -28,7 +27,6 @@ class Level: self.gameplay = Gameplay( player = self.player, - status = self.status, field = self.field, enemies = self.enemies, stats = self.stats) @@ -36,7 +34,8 @@ class Level: self.status, self.field, self.enemies, - self.level_info] + self.level_info, + self.player] def step(self, dt): self.status.update(dt = dt) @@ -53,11 +52,8 @@ class Level: return False else: - self.player_single = pygame.sprite.GroupSingle( - sprite = self.player.get_top_sprite()) self.stats.update_bonus(dt) if self.gameplay.step(): - self.player_single = pygame.sprite.Group() self.ended = True if self.stats.lives: self.endscreen = Show(levelup_screen(self.stats)) @@ -65,6 +61,6 @@ class Level: self.endscreen = Show(gameover_screen()) self.obj_classes.append(self.endscreen) - self.display.update(self.obj_classes+[self.player_single]) + self.display.update(self.obj_classes) return True diff --git a/src/sliceitoff/game/show.py b/src/sliceitoff/game/show.py index b9b684b..94e2540 100644 --- a/src/sliceitoff/game/show.py +++ b/src/sliceitoff/game/show.py @@ -11,7 +11,7 @@ class Show(pygame.sprite.Group): self.explode = False self.fadeout = 1_000 self.timeout = 15_000 - + def update(self, dt = 0, **kwargs): """ First timeout then fadeout and then inactivity """ super().update(dt = dt, explode = self.explode, **kwargs) @@ -29,4 +29,4 @@ class Show(pygame.sprite.Group): def sprites(self): """ Return sprites only when active """ - return super().sprites() if self.active else []
\ No newline at end of file + return super().sprites() if self.active else [] |