Home>

began to create a game in Pygame. I decided to add the FPS counter, but nothing happened to me. Nowhere in Google, I did not find a response.
Tell me how to do it?

p.s. I well, a very novice programmer. If my question seemed to you stupid, this is normal.

  • Answer # 1

    Try this way:

    Import Time
        While True:
            start_time= time.time () # Start Time of the Loop
        Print ("FPS:", 1.0 /(time.time () -start_time))
    

    or:

    Import Time
    start_time= time.time ()
    X= 1 # Displays The Frame Rate Every 1 Second
    Counter= 0.
    While True:
        Counter += 1
        if (time.time () -start_time) >
     x:
            Print ("FPS:", Counter /(Time.time () -start_time))
            Counter= 0.
            start_time= time.time ()