diff options
Diffstat (limited to 'src/sliceitoff/game/level.py')
-rw-r--r-- | src/sliceitoff/game/level.py | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/sliceitoff/game/level.py b/src/sliceitoff/game/level.py index 15668a4..f0bb871 100644 --- a/src/sliceitoff/game/level.py +++ b/src/sliceitoff/game/level.py @@ -9,16 +9,24 @@ from stats import Stats from screens import levelup_screen, gameover_screen, level_screen from .gameplay import Gameplay from .anykey import anykey +from .show import Show class Level: """ One level that can be played """ def __init__(self, display = None): self.display = display + self.ended = False self.status = Status() self.field = Field() self.enemies = Enemies() self.player = Player() + self.player_single = pygame.sprite.Group() + + self.level_info = Show(level_screen()) + self.game_over = Show(gameover_screen(), active = False) + self.levelup = Show(levelup_screen(), active = False) + self.gameplay = Gameplay( player = self.player, status = self.status, @@ -27,37 +35,40 @@ class Level: self.obj_classes = [ self.status, self.field, - self.enemies] - self.level_info = level_screen() - self.level_over = None + self.enemies, + self.game_over, + self.levelup, + self.level_info] def step(self, dt): - for obj in self.obj_classes: - obj.update(dt = dt) - + self.status.update(dt = dt) + self.field.update(dt = dt) + self.enemies.update(dt = dt) self.enemies.hit_walls(self.field.active_sprites()) - objs = self.obj_classes[:] - if self.level_info: - if anykey(): - self.level_info = None + if self.level_info.active: + self.level_info.update(dt = dt) + + elif self.ended: + if self.game_over.active: + self.game_over.update(dt = dt) + elif self.levelup.active: + self.levelup.update(dt = dt) else: - objs += [self.level_info] - elif self.level_over: - objs += [self.level_over] - if anykey(): return False + else: - objs += [pygame.sprite.GroupSingle( - sprite = self.player.get_top_sprite())] + self.player_single = pygame.sprite.GroupSingle( + sprite = self.player.get_top_sprite()) Stats.update_bonus(dt) if self.gameplay.step(): + self.player_single = pygame.sprite.Group() + self.ended = True if Stats.lives: - self.level_over = levelup_screen() + self.levelup.active = True else: - self.level_over = gameover_screen() + self.game_over.active = True - self.display.update(objs) - + self.display.update(self.obj_classes+[self.player_single]) return True |