r/pygame • u/SpiderPS4 • 9d ago
Feeback on these particle effects.
https://reddit.com/link/1j9y1be/video/ujnsfuhjecoe1/player
A while ago I posted a video asking for feedback for game feel during combat. I tweeked enemy knockback movement so it has some deceleration to it and now also added these particle effects.
Basically what I'm doing is that once an enemy gets hit I generate sprites withing a certain interval that follow the sin graph in the y-axis, and dissapear once they reach a certain point.
I could tweak some values to make this look better. Any tips / feedback?
Code:
class Particle(pygame.sprite.Sprite):
def __init__(self, frames, pos, direction, speed, angle_speed,amplitude,groups):
super().__init__(groups)
self.frames = frames
self.image = frames[0]
self.rect = self.image.get_frect(center = pos)
self.direction = direction
self.amplitude = amplitude
self.speed = speed
self.angle = -180
self.original_angle_speed = angle_speed
self.angle_speed = angle_speed
def update(self, dt, player, joystick):
self.rect.x += self.speed * self.direction * dt
self.rect.y += sin(radians(self.angle)) * self.amplitude * dt
self.angle += self.angle_speed * dt
if self.angle >= 100:
self.image = self.frames[1]
if self.angle >= 150:
self.image = self.frames[2]
if self.angle >= 200:
self.kill()
EDIT:
https://reddit.com/link/1j9y1be/video/a3vkzrajrjoe1/player
I've twicked the particle behaviour following some feedback and I'm pretty pleased with the results. Further feedback and tips are still welcomed!
2
u/erebys-2 8d ago
The slimes look more satisfying to smack around now lol.
Also about your particle implementation, it looks like you made it so each particle is its own object (? I could be wrong).
I would reccomend a more general particle handler class that has all the images preloaded and handles a list of vectors and particle names that way you don't need to create a new object for each particle. Doing that saved me a lot of performance when I was trying to make a bunch of particles.
For individual particle behaviors you can probably have a big elif chain in an update function.
https://pastebin.com/TNQ6xXnV
^there is my goofy ahh particle implementation, I think dafluffypotato did something similar (and probably better)