API reference
Track and limit framerate of a program.
- class tcod.clock.Clock
Bases:
objectMeasure framerate performance and sync to a given framerate.
Everything important is handled by
Clock.sync. You can use the fps properties to track the performance of an application.Time is sampled with
time.perf_counter.Example:
import tcod.clock clock = tcod.clock.Clock() while True: clock.sync(1 / 30) # This loop will run at 30 FPS until interrupted.
- last_time
Last time this Clock was synced.
- max_samples = 64
Number of framerate samples to log. This attribute be set in the class or instance.
- sync(desired_framerate=None)
Sync to a given framerate and return the delta time.
- time_samples
A recent collection of delta-time samples.