Skip to main content

Track and limit framerate of a program.

Project description

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=}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tcod-clock-1.0.1.tar.gz (12.1 kB view hashes)

Uploaded Source

Built Distribution

tcod_clock-1.0.1-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page