From 3bd0b957ef59ee64a9b511dfce70d56b43a0ff30 Mon Sep 17 00:00:00 2001 From: baggerfast Date: Sun, 26 Mar 2023 13:09:48 +0300 Subject: [PATCH] UPDATE: rework record scene, new ui --- pacman/scenes/records.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pacman/scenes/records.py b/pacman/scenes/records.py index 446a6c65..bcae94af 100644 --- a/pacman/scenes/records.py +++ b/pacman/scenes/records.py @@ -2,6 +2,7 @@ from pacman.data_core import Colors, PathManager from pacman.misc import Font +from pacman.misc.serializers import LevelStorage from pacman.objects import ButtonController, ImageObject, Text from pacman.scenes import base @@ -14,6 +15,9 @@ def create_static_objects(self): def create_objects(self) -> None: super().create_objects() + self.__indicator = Text(f"level {LevelStorage().current+1}", 12, font=Font.DEFAULT) + self.__indicator.move_center(self.game.width // 2, 55) + self.objects.append(self.__indicator) self.__create_text_labels() def create_buttons(self) -> None: @@ -41,12 +45,14 @@ def __create_text_labels(self) -> None: text_colors = [Colors.GOLD, Colors.SILVER, Colors.BRONZE, Colors.WHITE, Colors.WHITE] y = 4 for i in range(5): + text = "." * 12 if self.game.records.data[y] == 0 else str(self.game.records.data[y]) + text_color = Colors.WHITE if self.game.records.data[y] == 0 else text_colors[i] self.medals_text.append( Text( - str(self.game.records.data[y]), - 30, - pg.Rect(60, 55 + 35 * i, 0, 0), - text_colors[i], + text, + 25, + pg.Rect(60, 60 + 35 * i, 0, 0), + text_color, ) ) y -= 1 @@ -58,10 +64,9 @@ def __create_medals(self) -> None: ImageObject( self.game, PathManager.get_image_path(f"medal/{i}"), - (16, 55 + 35 * i), - ) + (16, 60 + 35 * i), + ).scale(30, 30) ) - self.__medals[i].scale(35, 35) def additional_draw(self, screen: pg.Surface) -> None: super().additional_draw(screen) @@ -70,7 +75,7 @@ def additional_draw(self, screen: pg.Surface) -> None: return y = 4 for i in range(5): - if self.game.records.data[y] != 0: + if y != -1: self.medals_text[i].process_draw(screen) self.__medals[i].process_draw(screen) y -= 1