schen357 commited on
Commit
8f8cea6
·
1 Parent(s): 8c11743

Create paddle.py

Browse files
Files changed (1) hide show
  1. paddle.py +26 -0
paddle.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PADDLE_DISTANCE = 30
2
+
3
+
4
+ class Paddle(Turtle):
5
+
6
+ def __init__(self, coordinates):
7
+ super().__init__()
8
+ self.shape("square")
9
+ self.shapesize(stretch_len=PADDLE_SIZE)
10
+ self.color("white")
11
+ self.speed("fastest")
12
+ self.setheading(90)
13
+ self.penup()
14
+ self.goto(coordinates)
15
+
16
+ def up(self):
17
+ if self.ycor() > 240:
18
+ pass
19
+ else:
20
+ self.forward(PADDLE_DISTANCE)
21
+
22
+ def down(self):
23
+ if self.ycor() < -240:
24
+ pass
25
+ else:
26
+ self.backward(PADDLE_DISTANCE)