import pygame from display import Display from status import Status from player import Player from field import Field from enemies import Enemies 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.status = Status() self.field = Field() self.enemies = Enemies() self.player = Player() self.player_single = pygame.sprite.Group() self.level_info = Show(level_screen()) self.ended = False self.endscreen = pygame.sprite.Group() self.gameplay = Gameplay( player = self.player, status = self.status, field = self.field, enemies = self.enemies) self.obj_classes = [ self.status, self.field, self.enemies, self.level_info] def step(self, dt): self.status.update(dt = dt) self.field.update(dt = dt) self.enemies.update(dt = dt) self.enemies.hit_walls(self.field.active_sprites()) if self.level_info.active: self.level_info.update(dt = dt) elif self.ended: if self.endscreen.active: self.endscreen.update(dt = dt) else: return False else: 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.endscreen = Show(levelup_screen()) else: self.endscreen = Show(gameover_screen()) self.obj_classes.append(self.endscreen) self.display.update(self.obj_classes+[self.player_single]) return True