simple2d-3d 0.2.2__tar.gz → 0.2.4__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.
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/PKG-INFO +1 -1
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/pyproject.toml +1 -1
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d/render.py +36 -19
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d.egg-info/PKG-INFO +1 -1
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/LICENSE +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/README.md +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/setup.cfg +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d/__init__.py +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d/colors.py +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d/gui.py +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d/setup.py +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d.egg-info/SOURCES.txt +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d.egg-info/dependency_links.txt +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d.egg-info/requires.txt +0 -0
- {simple2d_3d-0.2.2 → simple2d_3d-0.2.4}/simple2d_3d.egg-info/top_level.txt +0 -0
|
@@ -446,12 +446,14 @@ class ParticleSystem:
|
|
|
446
446
|
def __init__(self, renderer):
|
|
447
447
|
self.particles = []
|
|
448
448
|
self.cached_textures = {}
|
|
449
|
+
self.dst_rect = sdl2.SDL_Rect(0,0,,1,1)
|
|
449
450
|
|
|
450
451
|
def add_explosion(self, x, y, count=30):
|
|
451
452
|
for _ in range(count+1):
|
|
452
453
|
self.particles.append(Particle(x,y))
|
|
453
454
|
def update(self, dt):
|
|
454
455
|
self.particles = [p for p in self.particles if p.update(dt)]
|
|
456
|
+
|
|
455
457
|
def draw(self, renderer):
|
|
456
458
|
for p in self.particles:
|
|
457
459
|
alpha = max(0, min(255, int(p.life * 255)))
|
|
@@ -459,25 +461,40 @@ class ParticleSystem:
|
|
|
459
461
|
# --- 1. Only create the texture if it doesn't exist yet ---
|
|
460
462
|
if p.size not in self.cached_textures:
|
|
461
463
|
diameter = p.size * 2
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
464
|
+
|
|
465
|
+
# Using 0 for masks lets SDL2 automatically assign a standard, correct 32-bit RGBA layout
|
|
466
|
+
surface = sdl2.SDL_CreateRGBSurface(0, diameter, diameter, 32, 0, 0, 0, 0)
|
|
467
|
+
|
|
468
|
+
# Safety check: If SDL failed to allocate the surface memory, skip this frame
|
|
469
|
+
if not surface:
|
|
470
|
+
continue
|
|
471
|
+
|
|
472
|
+
# Fill the surface template with pure white
|
|
473
|
+
sdl2.SDL_FillRect(surface, None, sdl2.SDL_MapRGBA(surface.contents.format, 255, 255, 255, 255))
|
|
474
|
+
|
|
475
|
+
# Upload to GPU texture memory
|
|
476
|
+
texture = sdl2.SDL_CreateTextureFromSurface(renderer, surface)
|
|
477
|
+
sdl2.SDL_FreeSurface(surface)
|
|
478
|
+
|
|
479
|
+
if texture:
|
|
480
|
+
self.cached_textures[p.size] = texture
|
|
481
|
+
else:
|
|
482
|
+
continue # Skip if texture creation failed
|
|
467
483
|
|
|
468
|
-
# --- 2. Pull the texture and apply modifiers
|
|
469
|
-
tex = self.cached_textures
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
484
|
+
# --- 2. Pull the texture and apply modifiers ---
|
|
485
|
+
tex = self.cached_textures.get(p.size)
|
|
486
|
+
if not tex:
|
|
487
|
+
continue
|
|
488
|
+
|
|
489
|
+
sdl2.SDL_SetTextureColorMod(tex, p.color[0], p.color[1], p.color[2])
|
|
490
|
+
sdl2.SDL_SetTextureBlendMode(tex, sdl2.SDL_BLENDMODE_BLEND)
|
|
491
|
+
sdl2.SDL_SetTextureAlphaMod(tex, alpha)
|
|
473
492
|
|
|
474
|
-
# --- 3. Set the position box
|
|
475
|
-
dst_rect =
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
p.size * 2
|
|
480
|
-
)
|
|
493
|
+
# --- 3. Set the position box ---
|
|
494
|
+
self.dst_rect.x = int(p.x - p.size)
|
|
495
|
+
self.dst_rect.y = int(p.y - p.size)
|
|
496
|
+
self.dst_rect.w = int(p.size * 2)
|
|
497
|
+
self.dst_rect.h = int(p.size * 2)
|
|
481
498
|
|
|
482
|
-
# --- 4. Render it
|
|
483
|
-
SDL_RenderCopy(renderer, tex, None, dst_rect)
|
|
499
|
+
# --- 4. Render it ---
|
|
500
|
+
sdl2.SDL_RenderCopy(renderer, tex, None, ctypes.byref(dst_rect))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|