Skip to content

HexDecimal/python-tcod-clock

Repository files navigation

About

PyPI PyPI - License Documentation Status codecov

Libtcod used to include a global framerate limiter which was eventually deprecated. This module was created as a replacement for that feature.

import time

import tcod.clock


FPS = 30

end_time = time.time() + 3  # Loop for 3 seconds.

clock = tcod.clock.Clock()
while time.time() < end_time:
    clock.sync(1 / FPS)  # This loop will run at 30 FPS until interrupted.

# Timing information can be checked.  Check the docs for more info.
print(f"{clock.last_fps=}")
print(f"{clock.min_fps=}")
print(f"{clock.max_fps=}")
print(f"{clock.mean_fps=}")
print(f"{clock.median_fps=}")

About

Track and limit the framerate of a Python program.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages