-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourt.py
50 lines (40 loc) · 1.27 KB
/
court.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
from turtle import Turtle
UP = 90
DOWN = 270
LEFT = 180
RIGHT = 0
LENGTH = 900
WIDTH = 600
class Court(Turtle):
def __init__(self):
super().__init__()
self.penup()
self.color("pink")
self.pensize(5)
self.goto(-450, -255)
# self.goto(-450, 255)
self.pendown()
self.court_draw()
def court_draw(self):
print("drawing court")
for _ in range(4):
# drawing length
if _ % 2 == 0 and _ != 0:
print(_)
self.pendown()
self.color("pink")
self.forward(LENGTH) # Forward turtle by l units
self.left(90) # Turn turtle by 90 degree
# drawing width
elif _ % 2 == 0 and _ == 0:
self.penup()
# self.color("grey")
self.forward(LENGTH) # Forward turtle by l units
self.left(90) # Turn turtle by 90 degree
else:
self.pendown()
self.color("brown")
self.forward(WIDTH) # Forward turtle by w units
self.left(UP) # Turn turtle by 90 degree
self.penup()
self.hideturtle()