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