-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspark.py
30 lines (21 loc) · 882 Bytes
/
spark.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
29
30
import pygame
# class inherets from pygame sprite class
# This class represents some object which appears in the game world
class Spark(pygame.sprite.Sprite):
def __init__(self, posX, posY, imagePathList):
# Initialize parent sprite class
super().__init__()
self.frameList = []
frameCount = len(imagePathList)
for i in range(frameCount):
self.frameList.append( pygame.image.load(imagePathList[i]) )
self.animationIndex = 0
self.image = self.frameList[self.animationIndex]
self.rect = self.image.get_rect(center = (posX, posY) )
def Animate(self):
self.animationIndex += 0.1
if self.animationIndex >= len(self.frameList):
self.animationIndex = 0
self.image = self.frameList[int(self.animationIndex)]
def update(self):
self.Animate()