From 48c8163609eea97e3fb2663282a3bca89ab95566 Mon Sep 17 00:00:00 2001 From: Yan Wittmann Date: Mon, 27 Mar 2023 12:54:09 +0200 Subject: [PATCH] Frame rate counter --- project/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/project/main.py b/project/main.py index 2c0dfbd..98f6d76 100644 --- a/project/main.py +++ b/project/main.py @@ -51,12 +51,13 @@ if what_to_run == 'level': ghost_character.position_scale = PositionScale((90, 50), (1, 1)) sprite_manager.add_ui_element(DrawLayers.OBJECTS, ghost_character) - text_1 = TextLabel("Frame: 0", 2, 110, 50, alignment="left") - text_1.position_scale.scale = (0.3, 0.3) - sprite_manager.add_ui_element(DrawLayers.UI, text_1) + calculated_frame_rate_text = TextLabel("Frame rate: 0", 2, 110, 70, alignment="left") + calculated_frame_rate_text.position_scale.scale = (0.3, 0.3) + sprite_manager.add_ui_element(DrawLayers.UI, calculated_frame_rate_text) while True: clock.tick(frame_rate) + calculated_frame_rate_text.text = f"Frame rate: {round(clock.get_fps())}" pygame_events: list[pygame.event.Event] = pygame.event.get() key_manager.update_key_events(pygame_events)