simple2d-3d 0.2.9__tar.gz → 0.3.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.
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/PKG-INFO +1 -1
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/pyproject.toml +1 -1
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d/render.py +16 -66
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d.egg-info/PKG-INFO +1 -1
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/LICENSE +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/README.md +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/setup.cfg +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d/__init__.py +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d/colors.py +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d/gui.py +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d/setup.py +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d.egg-info/SOURCES.txt +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d.egg-info/dependency_links.txt +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d.egg-info/requires.txt +0 -0
- {simple2d_3d-0.2.9 → simple2d_3d-0.3.0}/simple2d_3d.egg-info/top_level.txt +0 -0
|
@@ -423,12 +423,12 @@ def CreatePlatform2D(scene,map_data,w,h,space,x_offset,y_offset,cast_shadow=True
|
|
|
423
423
|
x += 1
|
|
424
424
|
|
|
425
425
|
class Particle:
|
|
426
|
-
def __init__(self, x, y):
|
|
426
|
+
def __init__(self, x, y , life=1.0):
|
|
427
427
|
self.x = x
|
|
428
428
|
self.y = y
|
|
429
429
|
self.vx = random.uniform(-2, 2)
|
|
430
430
|
self.vy = random.uniform(-3, 0)
|
|
431
|
-
self.life =
|
|
431
|
+
self.life = life
|
|
432
432
|
self.color = (
|
|
433
433
|
random.randint(200, 255),
|
|
434
434
|
random.randint(100, 200),
|
|
@@ -446,11 +446,10 @@ 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)
|
|
450
449
|
|
|
451
|
-
def add_explosion(self, x, y, count=30):
|
|
450
|
+
def add_explosion(self, x, y, count=30,life=1.0):
|
|
452
451
|
for _ in range(count+1):
|
|
453
|
-
self.particles.append(Particle(x,y))
|
|
452
|
+
self.particles.append(Particle(x,y,life))
|
|
454
453
|
def update(self, dt):
|
|
455
454
|
self.particles = [p for p in self.particles if p.update(dt)]
|
|
456
455
|
|
|
@@ -458,65 +457,16 @@ class ParticleSystem:
|
|
|
458
457
|
for p in self.particles:
|
|
459
458
|
alpha = max(0, min(255, int(p.life * 255)))
|
|
460
459
|
|
|
461
|
-
#
|
|
462
|
-
|
|
463
|
-
diameter = p.size * 2
|
|
464
|
-
radius = p.size
|
|
465
|
-
|
|
466
|
-
surface = sdl2.SDL_CreateRGBSurface(0, diameter, diameter, 32, 0, 0, 0, 0)
|
|
467
|
-
if not surface:
|
|
468
|
-
continue
|
|
469
|
-
|
|
470
|
-
# We need to manually color pixels to make a smooth circle shape
|
|
471
|
-
# Lock the surface so we can write directly to raw pixel memory safely
|
|
472
|
-
sdl2.SDL_LockSurface(surface)
|
|
473
|
-
|
|
474
|
-
# Convert the raw pixels array pointer to a usable ctypes format
|
|
475
|
-
pixels_ptr = ctypes.cast(surface.contents.pixels, ctypes.POINTER(ctypes.c_uint32))
|
|
476
|
-
pitch = surface.contents.pitch // 4 # 4 bytes per pixel (32-bit)
|
|
477
|
-
|
|
478
|
-
# Get the pixel format mapping for pure white
|
|
479
|
-
white_pixel = sdl2.SDL_MapRGBA(surface.contents.format, 255, 255, 255, 255)
|
|
480
|
-
transparent_pixel = sdl2.SDL_MapRGBA(surface.contents.format, 0, 0, 0, 0)
|
|
481
|
-
|
|
482
|
-
# Loop through every single coordinate inside our square bounding box
|
|
483
|
-
for y in range(diameter):
|
|
484
|
-
for x in range(diameter):
|
|
485
|
-
# Calculate distance from the center of the square using Pythagorean theorem
|
|
486
|
-
dx = x - radius
|
|
487
|
-
dy = y - radius
|
|
488
|
-
if (dx * dx + dy * dy) <= (radius * radius):
|
|
489
|
-
# Inside the circle radius? Color it solid white!
|
|
490
|
-
pixels_ptr[y * pitch + x] = white_pixel
|
|
491
|
-
else:
|
|
492
|
-
# Outside the circle? Keep it transparent
|
|
493
|
-
pixels_ptr[y * pitch + x] = transparent_pixel
|
|
494
|
-
|
|
495
|
-
sdl2.SDL_UnlockSurface(surface)
|
|
496
|
-
|
|
497
|
-
# Upload our brand-new round circle template straight to GPU memory
|
|
498
|
-
texture = sdl2.SDL_CreateTextureFromSurface(renderer, surface)
|
|
499
|
-
sdl2.SDL_FreeSurface(surface)
|
|
500
|
-
|
|
501
|
-
if texture:
|
|
502
|
-
self.cached_textures[p.size] = texture
|
|
503
|
-
else:
|
|
504
|
-
continue
|
|
460
|
+
# Set drawing color to match the particle's fade
|
|
461
|
+
sdl2.SDL_SetRenderDrawColor(renderer, p.color[0], p.color[1], p.color[2], alpha)
|
|
505
462
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
self.dst_rect.x = int(p.x - p.size)
|
|
517
|
-
self.dst_rect.y = int(p.y - p.size)
|
|
518
|
-
self.dst_rect.w = int(p.size * 2)
|
|
519
|
-
self.dst_rect.h = int(p.size * 2)
|
|
520
|
-
|
|
521
|
-
# --- 4. Render it ---
|
|
522
|
-
sdl2.SDL_RenderCopy(renderer, tex, None, ctypes.byref(self.dst_rect))
|
|
463
|
+
cx, cy = int(p.x), int(p.y)
|
|
464
|
+
r = int(p.size)
|
|
465
|
+
|
|
466
|
+
# Draw a smooth structural circle using horizontal scan lines
|
|
467
|
+
# This avoids calculating textures or needing sdl2.sdlgfx!
|
|
468
|
+
for dy in range(-r, r + 1):
|
|
469
|
+
# Calculate the width of the circle at this specific vertical row
|
|
470
|
+
lx = int((r * r - dy * dy) ** 0.5)
|
|
471
|
+
for dx in range(-lx, lx + 1):
|
|
472
|
+
sdl2.SDL_RenderDrawPoint(renderer, cx + dx, cy + dy)
|
|
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
|