Merge remote-tracking branch 'origin/main'

main
Jonas Wächter 2023-03-29 17:47:45 +02:00
commit d39262c65e
3 changed files with 22 additions and 3 deletions

View File

@ -5,10 +5,11 @@ import pygame.time
from level.Level import Level from level.Level import Level
from level.elements.LoadedLevel import LoadedLevel from level.elements.LoadedLevel import LoadedLevel
from level.selection.ScreenManager import ScreenManager from level.selection.ScreenManager import ScreenManager
from physics.SpriteManager import SpriteManager from physics.SpriteManager import SpriteManager, DrawLayers
from physics.TickData import TickData from physics.TickData import TickData
from sprite.SpritesheetManager import SpritesheetManager from sprite.SpritesheetManager import SpritesheetManager
from ui_elements.KeyManager import KeyManager from ui_elements.KeyManager import KeyManager
from ui_elements.TextLabel import TextLabel
class LevelScreenManager(ScreenManager): class LevelScreenManager(ScreenManager):
@ -21,6 +22,11 @@ class LevelScreenManager(ScreenManager):
self.loaded_level.level_screen_manager = self self.loaded_level.level_screen_manager = self
self.loaded_level.load_level(self.level) 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): def initialize(self):
pass pass
@ -30,8 +36,11 @@ class LevelScreenManager(ScreenManager):
def tick(self, tick_data: TickData): def tick(self, tick_data: TickData):
if tick_data.key_manager.is_keymap_down(KeyManager.KEY_ESCAPE): 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) self.main_loop.select_level_selection(self.level.theme)
pygame.time.delay(200)
def player_death(self): def player_death(self):
self.main_loop.player_death(self.level) self.main_loop.player_death(self.level)

View File

@ -64,6 +64,11 @@ class LevelSelectionScreenManager(ScreenManager):
self.theme_label.position_scale.scale = (0.5, 0.5) self.theme_label.position_scale.scale = (0.5, 0.5)
self.add_element(DrawLayers.UI, self.theme_label) self.add_element(DrawLayers.UI, self.theme_label)
self.back_button = TextLabel('BACK [ESC]', 610, 430, 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.main_loop.select_main_menu())
for i in range(0, LABEL_COUNT): for i in range(0, LABEL_COUNT):
label = TextLabel(str(i), OFFSET[0] + 30, OFFSET[1] + 60 + i * 50, font_size=65) label = TextLabel(str(i), OFFSET[0] + 30, OFFSET[1] + 60 + i * 50, font_size=65)
label.position_scale.scale = (0.5, 0.5) label.position_scale.scale = (0.5, 0.5)

View File

@ -18,6 +18,11 @@ class OptionsScreenManager(ScreenManager):
label.position_scale.scale = (1, 1) label.position_scale.scale = (1, 1)
self.create_button(name, label) self.create_button(name, label)
self.back_button = TextLabel('BACK [ESC]', 610, 430, 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.main_loop.select_main_menu())
def create_button(self, name: str, label: TextLabel): def create_button(self, name: str, label: TextLabel):
if name == "SMALL": if name == "SMALL":
label.add_click_listener(lambda click: self.make_small_screen(click)) label.add_click_listener(lambda click: self.make_small_screen(click))