-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaddle.py
More file actions
44 lines (36 loc) · 1.13 KB
/
paddle.py
File metadata and controls
44 lines (36 loc) · 1.13 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
41
42
43
44
import global_stuff
from entity import entity
class paddle(entity):
def __init__(self, x, y):
super().__init__(x,y)
self.length=20
self.actual_length=20
self.stick=False
self.shoot=False
def movepaddle(self, key, balls):
if key=='d':
max_d=min(3, global_stuff.cols-self.length-self.y+1)
self.y+=max_d
for ball in balls:
if ball.isstuck():
ball.movestuckball(max_d)
elif key=='a':
max_d=self.y-max(0, self.y-3)
self.y-=max_d
for ball in balls:
if ball.isstuck():
ball.movestuckball(-max_d)
def increasesize(self):
self.actual_length+=6
self.length=max(self.actual_length,6)
def decreasesize(self):
self.actual_length-=6
self.length=max(self.actual_length,6)
def get_left_coor(self):
return self.y
def get_right_coor(self):
return self.y+self.length
def get_length(self):
return self.length
def isstick(self):
return self.stick