deltatiming 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deltatiming-0.1.0/LICENSE +21 -0
- deltatiming-0.1.0/PKG-INFO +39 -0
- deltatiming-0.1.0/deltatiming/__init__.py +39 -0
- deltatiming-0.1.0/deltatiming.egg-info/PKG-INFO +39 -0
- deltatiming-0.1.0/deltatiming.egg-info/SOURCES.txt +8 -0
- deltatiming-0.1.0/deltatiming.egg-info/dependency_links.txt +1 -0
- deltatiming-0.1.0/deltatiming.egg-info/top_level.txt +1 -0
- deltatiming-0.1.0/pyproject.toml +22 -0
- deltatiming-0.1.0/readme.md +25 -0
- deltatiming-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 robert-ish
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deltatiming
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A clean, useful delta time library for games and simulations.
|
|
5
|
+
Author: robert-ish
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/deltatime
|
|
8
|
+
Project-URL: Repository, https://github.com/yourusername/deltatime
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# Deltatiming
|
|
16
|
+
Deltatiming is a library for making deltatime.
|
|
17
|
+
## Installation
|
|
18
|
+
```bash
|
|
19
|
+
pip install deltatiming
|
|
20
|
+
```
|
|
21
|
+
## Usage
|
|
22
|
+
```python
|
|
23
|
+
from deltatiming import Deltatime
|
|
24
|
+
dt = Deltatime()
|
|
25
|
+
dt.tick()
|
|
26
|
+
print('Estimated framerate: '+str(dt.get_framerate()))
|
|
27
|
+
```
|
|
28
|
+
## Available functions
|
|
29
|
+
### Deltatime.tick()
|
|
30
|
+
Needed to be called before Deltatime.get_delta() and Deltatime.get_framerate()
|
|
31
|
+
### Deltatime.get_delta()
|
|
32
|
+
Gets time after last tick() call.
|
|
33
|
+
### Deltatime.set_time_scale(value)
|
|
34
|
+
Sets time multiplier. Useful for speeding up/slowing down the whole script if the whole script uses deltatime.
|
|
35
|
+
### Deltatime.get_time_scale()
|
|
36
|
+
Returns current time scale.
|
|
37
|
+
### Deltatime.get_framerate(use_time_scale: bool)
|
|
38
|
+
Returns current framerate based on delta time.
|
|
39
|
+
use_time_scale defaults to False
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import time
|
|
2
|
+
class Deltatime:
|
|
3
|
+
def __init__(self):
|
|
4
|
+
self._last_time = time.perf_counter()
|
|
5
|
+
self._time_scale = 1.0
|
|
6
|
+
|
|
7
|
+
def tick(self):
|
|
8
|
+
"""Call this once per frame to update the internal timer."""
|
|
9
|
+
if not self._paused:
|
|
10
|
+
self._last_time = time.perf_counter()
|
|
11
|
+
|
|
12
|
+
def get_delta(self):
|
|
13
|
+
"""Returns the time since the last tick. Only valid after tick()."""
|
|
14
|
+
return (time.perf_counter() - self._last_time) * self._time_scale
|
|
15
|
+
|
|
16
|
+
def set_time_scale(self, value):
|
|
17
|
+
"""Changes the multiplier for get_delta(). This will change how fast the game goes if you use delta time everywhere."""
|
|
18
|
+
self._time_scale = value
|
|
19
|
+
|
|
20
|
+
def get_time_scale(self):
|
|
21
|
+
"""Gets the current multiplier for get_delta()"""
|
|
22
|
+
return self._time_scale
|
|
23
|
+
|
|
24
|
+
def get_framerate(self, use_time_scale: bool = False):
|
|
25
|
+
"""Returns current framerate based on delta."""
|
|
26
|
+
delta = self.get_delta()
|
|
27
|
+
if delta == 0:
|
|
28
|
+
return 0
|
|
29
|
+
if use_time_scale:
|
|
30
|
+
return 1.0 / delta
|
|
31
|
+
else:
|
|
32
|
+
real_delta = (time.perf_counter() - self._last_time)
|
|
33
|
+
if real_delta == 0:
|
|
34
|
+
return 0
|
|
35
|
+
return 1.0 / real_delta
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"Deltatime"
|
|
39
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deltatiming
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A clean, useful delta time library for games and simulations.
|
|
5
|
+
Author: robert-ish
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/deltatime
|
|
8
|
+
Project-URL: Repository, https://github.com/yourusername/deltatime
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# Deltatiming
|
|
16
|
+
Deltatiming is a library for making deltatime.
|
|
17
|
+
## Installation
|
|
18
|
+
```bash
|
|
19
|
+
pip install deltatiming
|
|
20
|
+
```
|
|
21
|
+
## Usage
|
|
22
|
+
```python
|
|
23
|
+
from deltatiming import Deltatime
|
|
24
|
+
dt = Deltatime()
|
|
25
|
+
dt.tick()
|
|
26
|
+
print('Estimated framerate: '+str(dt.get_framerate()))
|
|
27
|
+
```
|
|
28
|
+
## Available functions
|
|
29
|
+
### Deltatime.tick()
|
|
30
|
+
Needed to be called before Deltatime.get_delta() and Deltatime.get_framerate()
|
|
31
|
+
### Deltatime.get_delta()
|
|
32
|
+
Gets time after last tick() call.
|
|
33
|
+
### Deltatime.set_time_scale(value)
|
|
34
|
+
Sets time multiplier. Useful for speeding up/slowing down the whole script if the whole script uses deltatime.
|
|
35
|
+
### Deltatime.get_time_scale()
|
|
36
|
+
Returns current time scale.
|
|
37
|
+
### Deltatime.get_framerate(use_time_scale: bool)
|
|
38
|
+
Returns current framerate based on delta time.
|
|
39
|
+
use_time_scale defaults to False
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
deltatiming
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "deltatiming"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A clean, useful delta time library for games and simulations."
|
|
9
|
+
readme = "readme.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{name = "robert-ish"}
|
|
12
|
+
]
|
|
13
|
+
license = "MIT"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3"
|
|
16
|
+
]
|
|
17
|
+
requires-python = ">=3.7"
|
|
18
|
+
dependencies = []
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/yourusername/deltatime"
|
|
22
|
+
Repository = "https://github.com/yourusername/deltatime"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Deltatiming
|
|
2
|
+
Deltatiming is a library for making deltatime.
|
|
3
|
+
## Installation
|
|
4
|
+
```bash
|
|
5
|
+
pip install deltatiming
|
|
6
|
+
```
|
|
7
|
+
## Usage
|
|
8
|
+
```python
|
|
9
|
+
from deltatiming import Deltatime
|
|
10
|
+
dt = Deltatime()
|
|
11
|
+
dt.tick()
|
|
12
|
+
print('Estimated framerate: '+str(dt.get_framerate()))
|
|
13
|
+
```
|
|
14
|
+
## Available functions
|
|
15
|
+
### Deltatime.tick()
|
|
16
|
+
Needed to be called before Deltatime.get_delta() and Deltatime.get_framerate()
|
|
17
|
+
### Deltatime.get_delta()
|
|
18
|
+
Gets time after last tick() call.
|
|
19
|
+
### Deltatime.set_time_scale(value)
|
|
20
|
+
Sets time multiplier. Useful for speeding up/slowing down the whole script if the whole script uses deltatime.
|
|
21
|
+
### Deltatime.get_time_scale()
|
|
22
|
+
Returns current time scale.
|
|
23
|
+
### Deltatime.get_framerate(use_time_scale: bool)
|
|
24
|
+
Returns current framerate based on delta time.
|
|
25
|
+
use_time_scale defaults to False
|