Frame rate counter

main
Yan Wittmann 2023-03-27 12:54:09 +02:00
parent ac0b8dc2f5
commit 48c8163609
1 changed files with 4 additions and 3 deletions

View File

@ -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)