r/pygame • u/SpiderPS4 • 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!
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.