Skip to content
Snippets Groups Projects
Commit dd1507a9 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Changed font of labels

parent c4317039
No related branches found
No related tags found
1 merge request!28Resolve "Game time limit"
Pipeline #43814 passed
...@@ -4,4 +4,4 @@ plates: ...@@ -4,4 +4,4 @@ plates:
plate_delay: [ 5, 10 ] plate_delay: [ 5, 10 ]
game: game:
time_limit_seconds: 5.0 time_limit_seconds: 30.0
...@@ -45,5 +45,23 @@ ...@@ -45,5 +45,23 @@
"misc": { "misc": {
"tool_tip_delay": "1.5" "tool_tip_delay": "1.5"
} }
},
"#timer_label": {
"colours": {
"normal_text": "#000000"
},
"font": {
"size": 20,
"bold": 1
}
},
"#score_label": {
"colours": {
"normal_text": "#000000"
},
"font": {
"size": 20,
"bold": 1
}
} }
} }
\ No newline at end of file
...@@ -489,9 +489,9 @@ class PyGameGUI: ...@@ -489,9 +489,9 @@ class PyGameGUI:
def update_score_label(self, state): def update_score_label(self, state):
score = state["score"] score = state["score"]
self.score_label.set_text(f"Your Score is {score}") self.score_label.set_text(f"Your score is {score}")
def draw_time(self, remaining_time: timedelta): def update_remaining_time(self, remaining_time: timedelta):
hours, rem = divmod(remaining_time.seconds, 3600) hours, rem = divmod(remaining_time.seconds, 3600)
minutes, seconds = divmod(rem, 60) minutes, seconds = divmod(rem, 60)
display_time = f"{minutes}:{'%02d' % seconds}" display_time = f"{minutes}:{'%02d' % seconds}"
...@@ -509,7 +509,7 @@ class PyGameGUI: ...@@ -509,7 +509,7 @@ class PyGameGUI:
self.draw_counters(state) self.draw_counters(state)
self.draw_players(state) self.draw_players(state)
self.manager.draw_ui(self.main_window) self.manager.draw_ui(self.main_window)
self.draw_time(state["remaining_time"]) self.update_remaining_time(state["remaining_time"])
def init_ui_elements(self): def init_ui_elements(self):
self.manager = pygame_gui.UIManager((self.window_width, self.window_height)) self.manager = pygame_gui.UIManager((self.window_width, self.window_height))
...@@ -606,7 +606,7 @@ class PyGameGUI: ...@@ -606,7 +606,7 @@ class PyGameGUI:
text="GAMETIME", text="GAMETIME",
relative_rect=pygame.Rect( relative_rect=pygame.Rect(
(0, 0), (0, 0),
(button_width, button_height), (button_width * 1.5, button_height),
), ),
manager=self.manager, manager=self.manager,
object_id="#timer_label", object_id="#timer_label",
...@@ -717,13 +717,11 @@ class PyGameGUI: ...@@ -717,13 +717,11 @@ class PyGameGUI:
pygame.init() pygame.init()
pygame.font.init() pygame.font.init()
# self.setup_windows()
self.init_ui_elements()
pygame.display.set_caption("Simple Overcooked Simulator") pygame.display.set_caption("Simple Overcooked Simulator")
clock = pygame.time.Clock() clock = pygame.time.Clock()
self.init_ui_elements()
self.manage_button_visibility() self.manage_button_visibility()
# Game loop # Game loop
...@@ -736,6 +734,8 @@ class PyGameGUI: ...@@ -736,6 +734,8 @@ class PyGameGUI:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
self.running = False self.running = False
# UI Buttons:
if event.type == pygame_gui.UI_BUTTON_PRESSED: if event.type == pygame_gui.UI_BUTTON_PRESSED:
match event.ui_element: match event.ui_element:
case self.start_button: case self.start_button:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment