-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaddle.py
37 lines (32 loc) · 958 Bytes
/
paddle.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
from turtle import Turtle
class Paddle(Turtle):
def __init__(self, x, y, color):
super().__init__()
self.color("white", color)
self.penup()
self.goto(0, 290)
self.setheading(270)
# self.pendown()
for i in range(19):
self.pensize(3)
self.pendown()
self.forward(16)
self.penup()
self.forward(16)
self.setheading(0)
self.goto(x, y)
self.pendown()
self.showturtle()
self.shape(name='square')
self.turtlesize(stretch_wid=4, stretch_len=1)
# by default its 20*20
def up(self):
self.penup()
if -245 < self.ycor() < 240:
self.speed("fastest")
self.goto(self.xcor(), self.ycor()+20)
def down(self):
self.penup()
self.speed("fastest")
if -240 < self.ycor() < 245:
self.goto(self.xcor(), self.ycor()-20)