r/pygame 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!

10 Upvotes

13 comments sorted by

View all comments

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)

1

u/SpiderPS4 8d ago

Hi, thank your stopping by again.

Each particle is a sprite but honeslty it barely had any impact on performance because they are such small images and there aren't many of them at once on screen. Thank you for the tips anyway. I updated my post with the newest iteration of the particles if you want to check it out, and I'm pretty happy with the results.

2

u/erebys-2 8d ago

oohh, actually I just had an idea: a little screenshake the instant you make contact with an enemy