-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaddle.py
More file actions
40 lines (31 loc) · 949 Bytes
/
paddle.py
File metadata and controls
40 lines (31 loc) · 949 Bytes
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
from turtle import Turtle
MOVE_DISTANCE = 20
class Paddle(Turtle):
def __init__(self):
super().__init__()
self.penup()
self.shape("square")
self.color("white")
self.turtlesize(stretch_wid=1, stretch_len=5)
self.reset_position()
def move_right(self):
if self.xcor() <= 385:
self.fd(MOVE_DISTANCE)
def move_left(self):
if -385 <= self.xcor():
self.bk(MOVE_DISTANCE)
def reset_position(self):
self.setposition(0, -275)
def zone(self):
min_x = self.xcor() - 72
max_x = self.xcor() + 72
quartile_x_1 = (min_x + self.xcor()) / 2
quartile_x_3 = (self.xcor() + max_x) / 2
max_y = self.ycor() + 22
return {
"min_x": min_x,
"max_x": max_x,
"quartile_x_1": quartile_x_1,
"quartile_x_3": quartile_x_3,
"max_y": max_y,
}