| Name | pgcooldown JSON |
| Version |
0.2.14
JSON |
| download |
| home_page | None |
| Summary | A cooldown/counter class to wait for stuff in games |
| upload_time | 2024-09-04 14:52:25 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | None |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# IMPORTANT
Breaking change! Properties gone!
I was aware, that there is a slight overhead when using properties, but
during A benchmark, that difference turned out to be 17%.
Since this package is still marked as Alpha and probably nobody is using
it besides me, the interface is now changed from properties to functions
in all places.
Tests needed to be adapted, but run clean now (and also more exact using
`pytest.approx` instead of `round`.
The following properties now need to be called as functions:
```
cold -> cold()
cold.setter -> set_cold(bool)
hot -> hot()
temperature -> temperature()
temperature.setter -> set_to(val)
remaining -> remaining()
remaining.setter -> set_to(val)
normalized -> normalized()
v -> removed, just use instance()
```
As stated initially, this is 17% less overhead when testing for cold,
etc. Performance of LerpThing increased from 1.3mio calls to 1.8mio due
to this change.
Sorry for any inconvenience, if anybody is using this, but that bad
design decision needed to be fixed before any more people would use this.
---
# pgcooldown
Cooldown & co...
This module started with just the Cooldown class, which can be used check if a
specified time has passed. It is mostly indended to be used to control
objects in a game loop, but it is general enough for other purposes as well.
```py
fire_cooldown = Cooldown(1, cold=True)
while True:
if fire_shot and fire_cooldown.cold:
fire_cooldown.reset()
launch_bullet()
...
```
With the usage of Cooldown on ramp data (e.g. a Lerp between an opaque and a
fully transparent sprite over the time of n seconds), I came up with the
LerpThing. The LerpThing gives you exactly that. A lerp between `from` and
`to` mapped onto a `duration`.
```py
alpha = LerpThing(0, 255, 5)
while True:
...
sprite.set_alpha(alpha())
# or sprite.set_alpha(alpha.v)
if alpha.finished:
sprite.kill()
```
Finally, the need to use Cooldown for scheduling the creations of game
objects, the CronD class was added. It schedules functions to run after a
wait period.
Note, that CronD doesn't do any magic background timer stuff, it needs to be
updated in the game loop.
```py
crond = CronD()
crond.add(1, create_enemy(screen.center))
crond.add(2, create_enemy(screen.center))
crond.add(3, create_enemy(screen.center))
crond.add(4, create_enemy(screen.center))
while True:
...
crond.update()
```
## Installation
The project home is https://github.com/dickerdackel/pgcooldown
### Installing HEAD from github directly
```
pip install git+https://github.com/dickerdackel/pgcooldown
```
### Getting it from pypi
```
pip install pgcooldown
```
### Tarball from github
Found at https://github.com/dickerdackel/pgcooldown/releases
## Licensing stuff
This lib is under the MIT license.
Raw data
{
"_id": null,
"home_page": null,
"name": "pgcooldown",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Michael Lamertz <michael.lamertz@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/29/10/116d228310836c0173bdc6bf1f95cd54817178b0a4716d4434088df673bb/pgcooldown-0.2.14.tar.gz",
"platform": null,
"description": "# IMPORTANT\nBreaking change! Properties gone!\n\nI was aware, that there is a slight overhead when using properties, but\nduring A benchmark, that difference turned out to be 17%.\n\nSince this package is still marked as Alpha and probably nobody is using\nit besides me, the interface is now changed from properties to functions\nin all places.\n\nTests needed to be adapted, but run clean now (and also more exact using\n`pytest.approx` instead of `round`.\n\nThe following properties now need to be called as functions:\n\n```\n cold -> cold()\n cold.setter -> set_cold(bool)\n hot -> hot()\n temperature -> temperature()\n temperature.setter -> set_to(val)\n remaining -> remaining()\n remaining.setter -> set_to(val)\n normalized -> normalized()\n v -> removed, just use instance()\n```\n\nAs stated initially, this is 17% less overhead when testing for cold,\netc. Performance of LerpThing increased from 1.3mio calls to 1.8mio due\nto this change.\n\nSorry for any inconvenience, if anybody is using this, but that bad\ndesign decision needed to be fixed before any more people would use this.\n\n---\n\n# pgcooldown\n\nCooldown & co...\n\nThis module started with just the Cooldown class, which can be used check if a\nspecified time has passed. It is mostly indended to be used to control\nobjects in a game loop, but it is general enough for other purposes as well.\n\n```py\n fire_cooldown = Cooldown(1, cold=True)\n while True:\n if fire_shot and fire_cooldown.cold:\n fire_cooldown.reset()\n launch_bullet()\n\n ...\n```\n\nWith the usage of Cooldown on ramp data (e.g. a Lerp between an opaque and a\nfully transparent sprite over the time of n seconds), I came up with the\nLerpThing. The LerpThing gives you exactly that. A lerp between `from` and\n`to` mapped onto a `duration`.\n\n```py\n alpha = LerpThing(0, 255, 5)\n while True:\n ...\n sprite.set_alpha(alpha())\n # or sprite.set_alpha(alpha.v)\n\n if alpha.finished:\n sprite.kill()\n```\n\nFinally, the need to use Cooldown for scheduling the creations of game\nobjects, the CronD class was added. It schedules functions to run after a\nwait period.\n\nNote, that CronD doesn't do any magic background timer stuff, it needs to be\nupdated in the game loop.\n\n```py\n crond = CronD()\n crond.add(1, create_enemy(screen.center))\n crond.add(2, create_enemy(screen.center))\n crond.add(3, create_enemy(screen.center))\n crond.add(4, create_enemy(screen.center))\n\n while True:\n ...\n crond.update()\n```\n\n## Installation\n\nThe project home is https://github.com/dickerdackel/pgcooldown\n\n### Installing HEAD from github directly\n\n```\npip install git+https://github.com/dickerdackel/pgcooldown\n```\n\n### Getting it from pypi\n\n```\npip install pgcooldown\n```\n\n### Tarball from github\n\nFound at https://github.com/dickerdackel/pgcooldown/releases\n\n## Licensing stuff\n\nThis lib is under the MIT license.\n",
"bugtrack_url": null,
"license": null,
"summary": "A cooldown/counter class to wait for stuff in games",
"version": "0.2.14",
"project_urls": {
"bugtracker": "https://github.com/DickerDackel/pgcooldown/issues",
"changelog": "https://github.com/dickerdackel/pgcooldown/ChangeLog.md",
"homepage": "https://github.com/dickerdackel/pgcooldown"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "683cac79dfcd6302dfd43f4edb496445b80a6cb26ed9e4154f1efdf57a492eb7",
"md5": "4e00568811f617036ecd391f2dc630d1",
"sha256": "6f4195bedf02aaad391669e74b73dfcf107bda5356cde989048097fb9f0564f8"
},
"downloads": -1,
"filename": "pgcooldown-0.2.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4e00568811f617036ecd391f2dc630d1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9668,
"upload_time": "2024-09-04T14:52:23",
"upload_time_iso_8601": "2024-09-04T14:52:23.789952Z",
"url": "https://files.pythonhosted.org/packages/68/3c/ac79dfcd6302dfd43f4edb496445b80a6cb26ed9e4154f1efdf57a492eb7/pgcooldown-0.2.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2910116d228310836c0173bdc6bf1f95cd54817178b0a4716d4434088df673bb",
"md5": "5f8d7e5931fc53c3424ec8f7d6f839e9",
"sha256": "016fbee394d6f108ec42b215afd18d8222085bcb0ee1dd0add91cc23be16124b"
},
"downloads": -1,
"filename": "pgcooldown-0.2.14.tar.gz",
"has_sig": false,
"md5_digest": "5f8d7e5931fc53c3424ec8f7d6f839e9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10959,
"upload_time": "2024-09-04T14:52:25",
"upload_time_iso_8601": "2024-09-04T14:52:25.593017Z",
"url": "https://files.pythonhosted.org/packages/29/10/116d228310836c0173bdc6bf1f95cd54817178b0a4716d4434088df673bb/pgcooldown-0.2.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 14:52:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DickerDackel",
"github_project": "pgcooldown",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pgcooldown"
}