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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file tcod-clock-1.0.1.tar.gz.

File metadata

  • Download URL: tcod-clock-1.0.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for tcod-clock-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9f2974beb0cf47239929eefb1e7e1823126e43ce7ecac184736bc70540d310d7
MD5 423128dd078ad9a3acf78adfef7bd8b0
BLAKE2b-256 814b49ccef4579f5023a7150451bf752c8ad08a55701258cf57d3a52d3a7b907

See more details on using hashes here.

File details

Details for the file tcod_clock-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tcod_clock-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for tcod_clock-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80ec3d3948a6397f0e7667612d6c8f786ad9a551f7557b3f2027fc99c8d8ac46
MD5 c0482f1b8de9711370d2e39e707a0ea3
BLAKE2b-256 9aef633aac2b1663b1af760ac201d3f0224f25a3b6417359a729520061ec80fd

See more details on using hashes here.

Supported by

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