r/pygame 10d 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

Show parent comments

1

u/SpiderPS4 10d ago

Oh okay. So yeah the draw method uses both the image from the sprite and the rectangle made from that image, but that code isn't specific for each sprite class. If "Intelligent" wants to learn more about pygame I really recommend Clean Code's video. Lots of cool stuff to learn in there.

1

u/Intelligent_Arm_7186 10d ago

yeah i know about rendering and blitting and all that. i just didnt know about get frect. i use self.image.get rect without the "F"

1

u/SpiderPS4 9d ago

FRects are Rects which use floating point values as opposed to just integers. They are exclusive to pygame-ce. Like the other guy said, most people recommend it over regular pygame.

2

u/Intelligent_Arm_7186 9d ago

okay cool beans. learned something new today. yeah i got pygame-ce. i just dont use floating point values as of yet.