48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
import pygame.time
|
|
|
|
from level.Level import Level
|
|
from level.elements.LoadedLevel import LoadedLevel
|
|
from level.selection.ScreenManager import ScreenManager
|
|
from physics.SpriteManager import SpriteManager, DrawLayers
|
|
from physics.TickData import TickData
|
|
from sprite.SpritesheetManager import SpritesheetManager
|
|
from ui_elements.KeyManager import KeyManager
|
|
from ui_elements.TextLabel import TextLabel
|
|
|
|
|
|
class LevelScreenManager(ScreenManager):
|
|
def __init__(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, main_loop,
|
|
level: Level):
|
|
super().__init__(sprite_manager, spritesheet_manager, main_loop)
|
|
|
|
self.level = level
|
|
self.loaded_level = LoadedLevel(sprite_manager, spritesheet_manager)
|
|
self.loaded_level.level_screen_manager = self
|
|
self.loaded_level.load_level(self.level)
|
|
|
|
self.back_button = TextLabel('BACK [ESC]', 635, 460, font_size=30)
|
|
self.back_button.position_scale.scale = (0.5, 0.5)
|
|
self.add_element(DrawLayers.UI, self.back_button)
|
|
self.back_button.add_click_listener(lambda click: self.back_to_level_selection())
|
|
|
|
def initialize(self):
|
|
pass
|
|
|
|
def destroy(self):
|
|
super().destroy()
|
|
self.loaded_level.destroy_level()
|
|
|
|
def tick(self, tick_data: TickData):
|
|
if tick_data.key_manager.is_keymap_down(KeyManager.KEY_ESCAPE):
|
|
self.back_to_level_selection()
|
|
pygame.time.delay(250)
|
|
|
|
def back_to_level_selection(self):
|
|
self.main_loop.select_level_selection(self.level.theme)
|
|
|
|
def player_death(self):
|
|
self.main_loop.player_death(self.level)
|
|
|
|
def player_success(self):
|
|
self.main_loop.player_success(self.level)
|