-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ball.py
54 lines (41 loc) · 1.46 KB
/
Ball.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
from Character import *
class Ball(MovableObject):
def __init__(self, game, dic, stateDic, direction, pos, colissionManager):
super(Ball, self).__init__(game, dic, pos)
self.img_dic = dic
self.state_dic = stateDic
self.image = dic[direction]
self.state = stateDic[direction]
self.img_fading = (dic['f_1'], dic['f_2'], dic['f_3'])
self.width = self.image.get_rect().right
self.height = self.image.get_rect().bottom
self.damage = 1
self.colissionManager = colissionManager
def move(self):
self.state.move(self)
def moveRight(self):
if not self.colissionManager.checkRightColission(self):
self.pos = (self.pos[0] + 10, self.pos[1])
def moveLeft(self):
if not self.colissionManager.checkLeftColission(self):
self.pos = (self.pos[0] - 10, self.pos[1])
def fade(self):
if self.counter > 2:
self.deleteMe()
else:
self.image = self.img_fading[self.counter]
self.counter += 1
def changeFading(self):
self.state = self.state_dic['fading']
def paint(self):
self.game.paint(self.image, self.pos)
def getWidth(self):
return self.width
def getHeight(self):
return self.height
def deleteMe(self):
self.game.deleteBall(self)
def getDamage(self):
return self.damage
def getVelocity(self):
return 10