-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticles.py
28 lines (24 loc) · 953 Bytes
/
particles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pygame
from support import import_folder
class ParticleEffect(pygame.sprite.Sprite):
def __init__(self, pos, type):
super().__init__()
self.frame_index = 0
self.animation_speed = 0.5
if type == "jump":
self.frames = import_folder('./graphics/character/dust_particles/jump')
if type == "land":
self.frames = import_folder('./graphics/character/dust_particles/land')
if type == "explosion":
self.frames = import_folder('./graphics/enemy/explosion')
self.image = self.frames[self.frame_index]
self.rect = self.image.get_rect(center=pos)
def animate(self):
self.frame_index += self.animation_speed
if self.frame_index >= len(self.frames):
self.kill()
else:
self.image = self.frames[int(self.frame_index)]
def update(self, x_shift):
self.animate()
self.rect.x += x_shift