-1

so I am trying to display my fps in game, but whenver I try to use the pygame.time.Clock.get_fps function, it says it does not exict as an atribute

I tried:

clock = pygame.time.Clock print(clock.get_fps()) print(pygame.time.clock.get_fps()) print(pygame.time.Clock.get_fps())

as you see, I am desperate

aadnnn1
  • 53
  • 1
  • 4
  • Did you try to read the docs? – DeepSpace Mar 02 '21 at 18:26
  • 2
    You need to create an instance of the `Clock` class , e.g. `clock = pygame.time.Clock()`. From this instance you can get the fps with `clock.get_fps()`. See [`pygame.time.Clock`](https://www.pygame.org/docs/ref/time.html#pygame.time.Clock). – Rabbid76 Mar 02 '21 at 18:29

1 Answers1

3

You missed the parenthesis here,

clock = pygame.time.Clock #<=

it should be

clock = pygame.time.Clock()

that way you can get the methods of the time.Clock() class, ie get_fps().

nasc
  • 289
  • 3
  • 16