-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player_Effects.py
108 lines (92 loc) · 3.23 KB
/
Player_Effects.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import pygame, math, time
class Player_Effects():
# Methods or Functions
def __init__(self, imgs, speed, screenSize, waitMax = 10):
self.surfaces = []
for img in imgs:
surf = pygame.image.load(img)
surf = pygame.transform.scale(surf, (16,50))
self.surfaces += [surf]
self.frame = 0
self.waitCount = 0
self.waitMax = waitMax
self.maxFrame = len(self.surfaces)-1
self.surface = self.surfaces[self.frame]
self.rect = self.surface.get_rect()
self.speed = speed
self.radius = self.rect.width/2
self.screenWidth = screenSize[0]
self.screenHeight = screenSize[1]
self.attacked = False
self.select = False
self.ran = False
self.living = False
self.value = 0
self.neg = False
self.upframe = False
self.countframe = 0
def place(self, pt):
self.rect = self.rect.move(pt)
def place2(self, other):
self.rect.center = other.rect.center
def check(self, effect):
if self.frame == self.maxFrame:
effect.living = False
def move(self):
self.rect = self.rect.move(self.speed)
if self.frame < self.maxFrame:
self.frame += 1
else:
self.frame = 0
self.surface = self.surfaces[self.frame]
def animate(self):
if self.upframe == True:
if self.frame < self.maxFrame:
self.frame += self.countframe
else:
self.frame = 0
self.upframe = False
self.surface = self.surfaces[self.frame]
def update(self, other):
if self.frame < self.maxFrame and self.select == True:
self.frame += 1
other.frame += 1
if self.frame == self.maxFrame and self.select == True or other.frame == other.maxFrame and other.select == True:
other.frame = 0
self.frame = 0
self.surface = self.surfaces[self.frame]
other.surface = other.surfaces[other.frame]
def reset(self):
self.frame = 0
self.value = 0
def distToPoint(self, pt):
x1 = self.rect.center[0]
x2 = pt[0]
y1 = self.rect.center[1]
y2 = pt[1]
return math.sqrt(((x2-x1)**2)+((y2-y1)**2))
def wallCollide(self):
if(self.rect.top > 0):
self.rect.topleft = [0, -2500]
self.living = False
return True
return False
def lanimate(self):
if self.waitCount < self.waitMax:
self.waitCount += 1
else:
self.waitCount = 0
if self.frame == 0 and self.neg == False:
self.frame += 1
if self.frame == 1 and self.neg == False:
self.frame += 1
if self.frame == 2:
self.frame -= 1
self.neg = True
if self.frame == 1 and self.neg == True:
self.frame -= 1
self.neg = False
else:
self.frame = 0
# self.living = False
self.surface = self.surfaces[self.frame]