-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimator.py
More file actions
40 lines (28 loc) · 1.23 KB
/
Animator.py
File metadata and controls
40 lines (28 loc) · 1.23 KB
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
31
32
33
34
35
36
37
38
39
40
import pygame
class Animation():
def __init__(self, animCount, rootObject):
self.animCount = animCount
self.rootObject = rootObject
self.currentAnimFrame = 0
self.currentGameFrame = 0
self.speedGlobal = 1
def animateOnce(self, images, speedLocal):
if self.currentGameFrame == 61:
self.currentGameFrame = 0
if self.currentGameFrame % (60 // (self.animCount*self.speedGlobal*speedLocal)) == 0 and self.currentGameFrame != 0:
self.currentAnimFrame+=1
if self.currentAnimFrame == self.animCount:
self.currentAnimFrame = 0
return True
self.rootObject.image = images[self.currentAnimFrame]
self.currentGameFrame += 1
return False
def animateRepeat(self, images, speedLocal):
if self.currentGameFrame == 61:
self.currentGameFrame = 0
if self.currentGameFrame % (60 // (self.animCount*self.speedGlobal*speedLocal)) == 0 and self.currentGameFrame != 0:
self.currentAnimFrame+=1
if self.currentAnimFrame == self.animCount:
self.currentAnimFrame = 0
self.rootObject.image = images[self.currentAnimFrame]
self.currentGameFrame += 1