Skip to content

Commit

Permalink
UPDATE: rework record scene, new ui
Browse files Browse the repository at this point in the history
  • Loading branch information
BaggerFast committed Mar 26, 2023
1 parent 07ef607 commit 3bd0b95
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pacman/scenes/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 3bd0b95

Please sign in to comment.