Name | fpstimer JSON |
Version |
0.0.1
JSON |
| download |
home_page | https://github.com/asweigart/fpstimer |
Summary | A clock timer that provides sleep()-like features for maintaining a certain "frames per second" (FPS) framerate in Python 2 and 3. |
upload_time | 2019-08-15 23:29:40 |
maintainer | |
docs_url | None |
author | Al Sweigart |
requires_python | |
license | GPLv3+ |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
# fpstimer
A clock timer that provides sleep()-like features for maintaining a certain "frames per second" (FPS) framerate in Python 2 and 3.
Sometimes you'll want to slow down your computer so it doesn't run too fast for the user. For example, if you want to run a video game at 60 frames per second (FPS), but the game can render the graphics for the screen in less than 1/60 second, you'll need the program to pause for however much time is remaining in that 1/60 second. This varible amount of time can be calculated by FPS Timer.
Install
=======
pip install fpstimer
Usage
=====
The frame rate is set by passing the integer FPS to the FPSTimer() constructor. The FPSTimer object has an sleep() method that pauses for a variable amount of time needed to maintain that framerate.
For example, calling FPSTimer(10) creates a timer for 10 fps. Each "frame" should last for 1/10 of a second. Running your program without an FPS timer could cause your program to run too fast for the user, especially as CPUs get faster. After running the code for a single frame, calling sleep() will pause the program for however much is needed for the remaining 1/10 second for that frame. This pause is calculated from the last time that sleep() was called for the previous frame.
>>> import fpstimer
>>> timer = fpstimer.FPSTimer(60) # Make a timer that is set for 60 fps.
>>> for i in range(100): # Each iteration of this loop will last (at least) 1/60 of a second.
... # Do calculations/work for a single "frame" here.
... timer.sleep() # Pause just enough to have a 1/60 second wait since last fpstSleep() call.
Raw data
{
"_id": null,
"home_page": "https://github.com/asweigart/fpstimer",
"name": "fpstimer",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Al Sweigart",
"author_email": "al@inventwithpython.com",
"download_url": "https://files.pythonhosted.org/packages/bf/21/3661d769a596ca345a38f03e55e1b655bd647329a95efc7588bb1a1cddf1/fpstimer-0.0.1.tar.gz",
"platform": "",
"description": "# fpstimer\n\nA clock timer that provides sleep()-like features for maintaining a certain \"frames per second\" (FPS) framerate in Python 2 and 3.\n\nSometimes you'll want to slow down your computer so it doesn't run too fast for the user. For example, if you want to run a video game at 60 frames per second (FPS), but the game can render the graphics for the screen in less than 1/60 second, you'll need the program to pause for however much time is remaining in that 1/60 second. This varible amount of time can be calculated by FPS Timer.\n\nInstall\n=======\n\n pip install fpstimer\n\nUsage\n=====\n\nThe frame rate is set by passing the integer FPS to the FPSTimer() constructor. The FPSTimer object has an sleep() method that pauses for a variable amount of time needed to maintain that framerate.\n\nFor example, calling FPSTimer(10) creates a timer for 10 fps. Each \"frame\" should last for 1/10 of a second. Running your program without an FPS timer could cause your program to run too fast for the user, especially as CPUs get faster. After running the code for a single frame, calling sleep() will pause the program for however much is needed for the remaining 1/10 second for that frame. This pause is calculated from the last time that sleep() was called for the previous frame.\n\n >>> import fpstimer\n >>> timer = fpstimer.FPSTimer(60) # Make a timer that is set for 60 fps.\n >>> for i in range(100): # Each iteration of this loop will last (at least) 1/60 of a second.\n ... # Do calculations/work for a single \"frame\" here.\n ... timer.sleep() # Pause just enough to have a 1/60 second wait since last fpstSleep() call.",
"bugtrack_url": null,
"license": "GPLv3+",
"summary": "A clock timer that provides sleep()-like features for maintaining a certain \"frames per second\" (FPS) framerate in Python 2 and 3.",
"version": "0.0.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "2369a5e1145f2793a30897d737ae92a7",
"sha256": "fba3bcebfda796d2eb4251ea88e2b45b1f3909e05afa79812778d0d98c3acfca"
},
"downloads": -1,
"filename": "fpstimer-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "2369a5e1145f2793a30897d737ae92a7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 2883,
"upload_time": "2019-08-15T23:29:40",
"upload_time_iso_8601": "2019-08-15T23:29:40.336432Z",
"url": "https://files.pythonhosted.org/packages/bf/21/3661d769a596ca345a38f03e55e1b655bd647329a95efc7588bb1a1cddf1/fpstimer-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2019-08-15 23:29:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "asweigart",
"github_project": "fpstimer",
"travis_ci": false,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "fpstimer"
}