pygame-renderkit 1.2.0__py3-none-any.whl

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.
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: pygame-renderkit
3
+ Version: 1.2.0
4
+ Summary: High-performance sprite batching and particle rendering for pygame
5
+ Home-page: https://github.com/devstudio-games/pygame-renderkit
6
+ Author: DevStudio Games
7
+ Author-email: dev@devstudio-games.example.com
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: pygame>=2.1.0
22
+ Requires-Dist: numpy>=1.21.0
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: license-file
30
+ Dynamic: requires-dist
31
+ Dynamic: requires-python
32
+ Dynamic: summary
33
+
34
+ # pygame-renderkit
35
+
36
+ High-performance sprite batching and particle rendering utilities for pygame.
37
+
38
+ ## Features
39
+
40
+ - **SpriteBatch**: GPU-friendly batch renderer with automatic layer sorting
41
+ - **ParticleSystem**: Optimized particle effects with up to 5000 particles
42
+ - **SpatialHash**: O(1) collision queries using grid-based spatial partitioning
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install pygame-renderkit
48
+ ```
49
+
50
+ ## Quick Start
51
+
52
+ ```python
53
+ import pygame
54
+ from renderkit import SpriteBatch, ParticleSystem
55
+
56
+ pygame.init()
57
+ screen = pygame.display.set_mode((800, 600))
58
+ clock = pygame.time.Clock()
59
+
60
+ batch = SpriteBatch()
61
+ particles = ParticleSystem()
62
+
63
+ running = True
64
+ while running:
65
+ dt = clock.tick(60) / 1000.0
66
+ for event in pygame.event.get():
67
+ if event.type == pygame.QUIT:
68
+ running = False
69
+ if event.type == pygame.MOUSEBUTTONDOWN:
70
+ particles.emit(*event.pos, count=50)
71
+ particles.update(dt)
72
+ screen.fill((20, 20, 30))
73
+ particles.draw(screen)
74
+ batch.draw(screen)
75
+ pygame.display.flip()
76
+
77
+ pygame.quit()
78
+ ```
79
+
80
+ ## License
81
+
82
+ MIT License
@@ -0,0 +1,9 @@
1
+ pygame_renderkit-1.2.0.dist-info/licenses/LICENSE,sha256=nvfELZ7DbHLIKD6UJxXN5FkAN_Xs4DoLCxnSyJi8XsM,1072
2
+ renderkit/__init__.py,sha256=iwvoNZE1NyyRYjSH2IppIUzk3bvbyiBAiQMhZEnjqwg,420
3
+ renderkit/particle_system.py,sha256=Wvn6neMxPFpdWhjmOlX20A6cxgc8bkDJ8Tc7CuyQeE8,1056
4
+ renderkit/spatial_hash.py,sha256=82Xshl0Swi5QWAjd7v1YqWoZP6YVgnpCcMnsJrIiiJQ,1187
5
+ renderkit/sprite_batch.py,sha256=Fjsr0m2r5JTLrQQLwZNm9yNbheqTgfNnREyX9XqXgf0,730
6
+ pygame_renderkit-1.2.0.dist-info/METADATA,sha256=1cQC1ZWy7Dqmxt3WctpjGF3MXwV_-p1m_i_xEyuDuZ4,2299
7
+ pygame_renderkit-1.2.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
8
+ pygame_renderkit-1.2.0.dist-info/top_level.txt,sha256=u7TfK8VNTYILwvAAnORHsSvUxNXnd4LzOKtqe_E_Pj0,10
9
+ pygame_renderkit-1.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 DevStudio Games
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 @@
1
+ renderkit
renderkit/__init__.py ADDED
@@ -0,0 +1,14 @@
1
+ """
2
+ pygame-renderkit: High-performance sprite batching for pygame
3
+ Provides optimized sprite batch rendering, particle systems, and
4
+ collision-optimized spatial hashing for 2D games.
5
+ """
6
+
7
+ __version__ = '1.2.0'
8
+ __author__ = 'DevStudio Games'
9
+
10
+ from .sprite_batch import SpriteBatch
11
+ from .particle_system import ParticleSystem
12
+ from .spatial_hash import SpatialHash
13
+
14
+ __all__ = ['SpriteBatch', 'ParticleSystem', 'SpatialHash']
@@ -0,0 +1,29 @@
1
+ """Particle system for visual effects."""
2
+ import random
3
+ import pygame
4
+
5
+ class ParticleSystem:
6
+ """GPU-friendly particle system with batch updates."""
7
+ def __init__(self, max_particles=5000):
8
+ self.max_particles = max_particles
9
+ self.particles = []
10
+ def emit(self, x, y, count=10, color=(255, 100, 50)):
11
+ for _ in range(count):
12
+ self.particles.append({
13
+ 'x': x, 'y': y,
14
+ 'vx': random.uniform(-2, 2),
15
+ 'vy': random.uniform(-5, -1),
16
+ 'life': random.uniform(0.5, 2.0),
17
+ 'color': color,
18
+ 'size': random.randint(2, 6)
19
+ })
20
+ def update(self, dt):
21
+ for p in self.particles:
22
+ p['x'] += p['vx']
23
+ p['y'] += p['vy']
24
+ p['life'] -= dt
25
+ self.particles = [p for p in self.particles if p['life'] > 0]
26
+ def draw(self, surface):
27
+ for p in self.particles:
28
+ pygame.draw.circle(surface, p['color'],
29
+ (int(p['x']), int(p['y'])), p['size'])
@@ -0,0 +1,30 @@
1
+ """Spatial hashing for collision detection."""
2
+
3
+ class SpatialHash:
4
+ """Grid-based spatial partitioning for O(1) collision queries."""
5
+ def __init__(self, cell_size=64):
6
+ self.cell_size = cell_size
7
+ self.cells = {}
8
+ def _key(self, x, y):
9
+ return (int(x // self.cell_size), int(y // self.cell_size))
10
+ def insert(self, obj, rect):
11
+ min_cell = self._key(rect.left, rect.top)
12
+ max_cell = self._key(rect.right, rect.bottom)
13
+ for cx in range(min_cell[0], max_cell[0] + 1):
14
+ for cy in range(min_cell[1], max_cell[1] + 1):
15
+ k = (cx, cy)
16
+ if k not in self.cells:
17
+ self.cells[k] = []
18
+ self.cells[k].append(obj)
19
+ def query(self, rect):
20
+ result = set()
21
+ min_cell = self._key(rect.left, rect.top)
22
+ max_cell = self._key(rect.right, rect.bottom)
23
+ for cx in range(min_cell[0], max_cell[0] + 1):
24
+ for cy in range(min_cell[1], max_cell[1] + 1):
25
+ k = (cx, cy)
26
+ if k in self.cells:
27
+ result.update(self.cells[k])
28
+ return list(result)
29
+ def clear(self):
30
+ self.cells.clear()
@@ -0,0 +1,21 @@
1
+ """Optimized sprite batch renderer."""
2
+ import pygame
3
+
4
+ class SpriteBatch:
5
+ """Batch renderer for pygame sprites with layer sorting."""
6
+ def __init__(self, max_sprites=10000):
7
+ self.max_sprites = max_sprites
8
+ self.sprites = []
9
+ self._dirty = True
10
+ def add(self, sprite, layer=0):
11
+ self.sprites.append((layer, sprite))
12
+ self._dirty = True
13
+ def remove(self, sprite):
14
+ self.sprites = [s for s in self.sprites if s[1] != sprite]
15
+ self._dirty = True
16
+ def draw(self, surface):
17
+ if self._dirty:
18
+ self.sprites.sort(key=lambda x: x[0])
19
+ self._dirty = False
20
+ for _, sprite in self.sprites:
21
+ surface.blit(sprite.image, sprite.rect)