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,#,#,#,#,#,#,#,#,#,#
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||||
AG,11,id=lever_1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
AG,11,id=lever_1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||||
|
|
|
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "level-01",
|
"name": "level-01",
|
||||||
"theme": "castle",
|
"theme": "cave",
|
||||||
"abilities": [
|
"abilities": [
|
||||||
],
|
],
|
||||||
"file": "level-01.csv"
|
"file": "level-01.csv"
|
||||||
|
@ -22,14 +22,14 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "level-03",
|
"name": "level-03",
|
||||||
"theme": "castle",
|
"theme": "cave",
|
||||||
"abilities": [
|
"abilities": [
|
||||||
],
|
],
|
||||||
"file": "level-03.csv"
|
"file": "level-03.csv"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "level-04",
|
"name": "level-04",
|
||||||
"theme": "castle",
|
"theme": "cave",
|
||||||
"abilities": [
|
"abilities": [
|
||||||
],
|
],
|
||||||
"file": "level-04.csv"
|
"file": "level-04.csv"
|
||||||
|
|
|
@ -4,10 +4,12 @@ from level.Level import Level
|
||||||
from level.LevelManager import LevelManager
|
from level.LevelManager import LevelManager
|
||||||
from level.selection.ScreenManager import ScreenManager
|
from level.selection.ScreenManager import ScreenManager
|
||||||
from physics.SpriteManager import SpriteManager, DrawLayers
|
from physics.SpriteManager import SpriteManager, DrawLayers
|
||||||
|
from physics.TickData import TickData
|
||||||
from sprite.PositionScale import PositionScale
|
from sprite.PositionScale import PositionScale
|
||||||
from sprite.SpritesheetManager import SpritesheetManager
|
from sprite.SpritesheetManager import SpritesheetManager
|
||||||
from sprite.StaticSprite import StaticSprite
|
from sprite.StaticSprite import StaticSprite
|
||||||
from ui_elements.ClickEvent import ClickEvent
|
from ui_elements.ClickEvent import ClickEvent
|
||||||
|
from ui_elements.KeyManager import KeyManager
|
||||||
from ui_elements.TextLabel import TextLabel
|
from ui_elements.TextLabel import TextLabel
|
||||||
|
|
||||||
LABEL_COUNT = 10
|
LABEL_COUNT = 10
|
||||||
|
@ -77,9 +79,62 @@ class LevelSelectionScreenManager(ScreenManager):
|
||||||
label.set_text('')
|
label.set_text('')
|
||||||
label.click_listeners = []
|
label.click_listeners = []
|
||||||
|
|
||||||
for id, level in enumerate(self.levels_by_theme[self.selected_theme]):
|
levels = self.levels_by_theme[self.selected_theme]
|
||||||
self.level_labels[id].set_text(level.name)
|
|
||||||
self.level_labels[id].add_click_listener(lambda click: self.select_level(click, level))
|
if len(levels) > 0:
|
||||||
|
self.level_labels[0].set_text(levels[0].name)
|
||||||
|
self.level_labels[0].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[0])
|
||||||
|
)
|
||||||
|
if len(levels) > 1:
|
||||||
|
self.level_labels[1].set_text(levels[1].name)
|
||||||
|
self.level_labels[1].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[1])
|
||||||
|
)
|
||||||
|
if len(levels) > 2:
|
||||||
|
self.level_labels[2].set_text(levels[2].name)
|
||||||
|
self.level_labels[2].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[2])
|
||||||
|
)
|
||||||
|
if len(levels) > 3:
|
||||||
|
self.level_labels[3].set_text(levels[3].name)
|
||||||
|
self.level_labels[3].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[3])
|
||||||
|
)
|
||||||
|
if len(levels) > 4:
|
||||||
|
self.level_labels[4].set_text(levels[4].name)
|
||||||
|
self.level_labels[4].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[4])
|
||||||
|
)
|
||||||
|
if len(levels) > 5:
|
||||||
|
self.level_labels[5].set_text(levels[5].name)
|
||||||
|
self.level_labels[5].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[5])
|
||||||
|
)
|
||||||
|
if len(levels) > 6:
|
||||||
|
self.level_labels[6].set_text(levels[6].name)
|
||||||
|
self.level_labels[6].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[6])
|
||||||
|
)
|
||||||
|
if len(levels) > 7:
|
||||||
|
self.level_labels[7].set_text(levels[7].name)
|
||||||
|
self.level_labels[7].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[7])
|
||||||
|
)
|
||||||
|
if len(levels) > 8:
|
||||||
|
self.level_labels[8].set_text(levels[8].name)
|
||||||
|
self.level_labels[8].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[8])
|
||||||
|
)
|
||||||
|
if len(levels) > 9:
|
||||||
|
self.level_labels[9].set_text(levels[9].name)
|
||||||
|
self.level_labels[9].add_click_listener(
|
||||||
|
lambda click: self.select_level(click, levels[9])
|
||||||
|
)
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
super().destroy()
|
super().destroy()
|
||||||
|
|
||||||
|
def tick(self, tick_data: TickData):
|
||||||
|
if tick_data.key_manager.is_keymap_down(KeyManager.KEY_ESCAPE):
|
||||||
|
self.main_loop.select_main_menu()
|
|
@ -1,16 +1,40 @@
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
|
|
||||||
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 sprite.SpritesheetManager import SpritesheetManager
|
from sprite.SpritesheetManager import SpritesheetManager
|
||||||
|
from ui_elements import CoordinateTransform
|
||||||
|
from ui_elements.KeyManager import KeyManager
|
||||||
|
from ui_elements.TextLabel import TextLabel
|
||||||
|
from ui_elements.ClickEvent import ClickEvent
|
||||||
|
|
||||||
|
|
||||||
class MainMenuScreenManager(ScreenManager):
|
class MainMenuScreenManager(ScreenManager):
|
||||||
def __init__(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager,main_loop):
|
def __init__(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, main_loop):
|
||||||
super().__init__(sprite_manager, spritesheet_manager, main_loop)
|
super().__init__(sprite_manager, spritesheet_manager, main_loop)
|
||||||
|
|
||||||
|
def go_to_menu(self, click):
|
||||||
|
if click.is_click_down(ClickEvent.CLICK_LEFT):
|
||||||
|
self.main_loop.select_level_selection()
|
||||||
|
|
||||||
|
def go_to_options_screen(self, click):
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
pass
|
size = CoordinateTransform.transform_screen_to_world(self.main_loop.window_size, self.main_loop.screen_transform)
|
||||||
|
|
||||||
|
self.create_button("START", size[0] * 0.5, size[1] * 0.5)
|
||||||
|
self.create_button("OPTIONS", size[0] * 0.5, size[1] * 0.65)
|
||||||
|
|
||||||
|
def create_button(self, name: str, x_position, y_position):
|
||||||
|
label = TextLabel(name, x_position, y_position, font_size=70, alignment="center")
|
||||||
|
self.add_element(DrawLayers.UI, label)
|
||||||
|
label.position_scale.scale = (1, 1)
|
||||||
|
if name == "START":
|
||||||
|
label.add_click_listener(lambda click: self.go_to_menu(click))
|
||||||
|
elif name == "OPTIONS":
|
||||||
|
label.add_click_listener(lambda click: self.go_to_options_screen(click))
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
super().destroy()
|
super().destroy()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import sys
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
|
@ -68,7 +67,7 @@ class MainLoop:
|
||||||
|
|
||||||
self.screen_manager: Optional[ScreenManager] = None
|
self.screen_manager: Optional[ScreenManager] = None
|
||||||
self.game_state = self.GAME_STATE_MENU
|
self.game_state = self.GAME_STATE_MENU
|
||||||
self.set_game_state(self.GAME_STATE_LEVEL_SELECTION)
|
self.set_game_state(self.GAME_STATE_MENU)
|
||||||
|
|
||||||
self.level: Optional[Level] = None
|
self.level: Optional[Level] = None
|
||||||
|
|
||||||
|
@ -98,6 +97,9 @@ class MainLoop:
|
||||||
if self.screen_manager is not None and isinstance(self.screen_manager, LevelSelectionScreenManager):
|
if self.screen_manager is not None and isinstance(self.screen_manager, LevelSelectionScreenManager):
|
||||||
self.screen_manager.select_theme(theme)
|
self.screen_manager.select_theme(theme)
|
||||||
|
|
||||||
|
def select_main_menu(self):
|
||||||
|
self.set_game_state(self.GAME_STATE_MENU)
|
||||||
|
|
||||||
def set_game_state(self, game_state: str):
|
def set_game_state(self, game_state: str):
|
||||||
self.game_state = game_state
|
self.game_state = game_state
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue