add next steps for level menu
parent
4c66ff4a10
commit
417c28bd60
|
@ -18,7 +18,7 @@ from ui_elements.KeyManager import KeyManager
|
||||||
from ui_elements.LevelMenu import LevelMenu
|
from ui_elements.LevelMenu import LevelMenu
|
||||||
from ui_elements.TextLabel import TextLabel
|
from ui_elements.TextLabel import TextLabel
|
||||||
|
|
||||||
what_to_run = 'level'
|
what_to_run = 'menu'
|
||||||
|
|
||||||
|
|
||||||
def apply_frame_rate(number: float):
|
def apply_frame_rate(number: float):
|
||||||
|
@ -77,8 +77,8 @@ if what_to_run == 'menu':
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
quit()
|
quit()
|
||||||
elif event.type == pygame.MOUSEBUTTONDOWN:
|
# elif event.type == pygame.MOUSEBUTTONDOWN:
|
||||||
generated_level.load_level(parsed_levels_manager.levels[0])
|
# generated_level.load_level(parsed_levels_manager.levels[0])
|
||||||
|
|
||||||
screen.fill((0, 0, 0))
|
screen.fill((0, 0, 0))
|
||||||
# level_menu.draw(screen, screen_transform)
|
# level_menu.draw(screen, screen_transform)
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
|
import copy
|
||||||
|
|
||||||
|
import pygame
|
||||||
|
|
||||||
from level.Level import Level
|
from level.Level import Level
|
||||||
|
from ui_elements.ClickEvent import ClickEvent
|
||||||
from ui_elements.TextLabel import TextLabel
|
from ui_elements.TextLabel import TextLabel
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +29,7 @@ class LevelMenu:
|
||||||
text_label = TextLabel(level.name, current_text_label_x, current_text_label_y, 60)
|
text_label = TextLabel(level.name, current_text_label_x, current_text_label_y, 60)
|
||||||
text_label.position_scale.scale = (0.5, 0.5)
|
text_label.position_scale.scale = (0.5, 0.5)
|
||||||
# text_label = TextLabel(self.extract_level(level.name), current_text_label_x, current_text_label_y, 35)
|
# text_label = TextLabel(self.extract_level(level.name), current_text_label_x, current_text_label_y, 35)
|
||||||
text_label.add_click_listener(lambda: self.level_select_listener(level))
|
text_label.add_click_listener(lambda click_event: self.handle_level_text_label_click(click_event, level))
|
||||||
self.level_text_labels.append(text_label)
|
self.level_text_labels.append(text_label)
|
||||||
|
|
||||||
if (index + 1) % self.column_count == 0:
|
if (index + 1) % self.column_count == 0:
|
||||||
|
@ -33,5 +38,9 @@ class LevelMenu:
|
||||||
else:
|
else:
|
||||||
current_text_label_x += self.width / self.column_count
|
current_text_label_x += self.width / self.column_count
|
||||||
|
|
||||||
|
def handle_level_text_label_click(self, click_event: ClickEvent, level: Level):
|
||||||
|
if click_event.event.type == pygame.MOUSEBUTTONUP:
|
||||||
|
self.level_select_listener(level)
|
||||||
|
|
||||||
def extract_level(self):
|
def extract_level(self):
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -29,7 +29,7 @@ class UiElement:
|
||||||
|
|
||||||
def click(self, click_event):
|
def click(self, click_event):
|
||||||
for listener in self.click_listeners:
|
for listener in self.click_listeners:
|
||||||
listener(self, click_event)
|
listener(click_event)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def tick(self, tick_data: TickData):
|
def tick(self, tick_data: TickData):
|
||||||
|
|
Loading…
Reference in New Issue