-
Notifications
You must be signed in to change notification settings - Fork 0
/
tg.py
99 lines (66 loc) · 1.82 KB
/
tg.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Coded by SpiderX360
# modules
import turtle as tt
import random
# Screen
tt.Screen()
tt.title("Turtle Game !")
tt.speed(0)
# Moving Part
walk = int(tt.textinput(title="Walk input", prompt="Define Turtle Walk Space !")).__floor__()
def Walk_up():
tt.forward(walk)
def Walk_down():
tt.back(walk)
def Walk_right():
tt.right(90)
# tt.forward(walk)
def Walk_left():
tt.left(90)
# tt.forward(walk)
def Middle():
tt.penup()
tt.setx(0)
tt.sety(0)
tt.pendown()
def Hide_turtle():
tt.hideturtle()
def Show_turtle():
tt.showturtle()
def Change_color():
color = ['black', 'blue', 'red', 'white', 'green', 'gold', 'maroon', 'violet', 'magenta', 'purple', 'navy',
'skyblue', 'cyan', 'turquoise', 'lightgreen', 'darkgreen', 'chocolate', 'brown', 'gray']
tt.bgcolor(f"{color[random.randrange(0, len(color))]}")
def Pen_color():
color = ['black', 'blue', 'red', 'white']
tt.pencolor(f"{color[random.randrange(0, len(color))]}")
def Exit():
tt.bye()
print("Exited...")
# def Save_image():
# ts = tt.getscreen()
# tt.getcanvas().postscript(file="image.emp")
while True:
# Listerner
tt.listen()
tt.onkeypress(Walk_up, 'w')
tt.onkeypress(Walk_left, 'a')
tt.onkeypress(Walk_right, 'd')
tt.onkeypress(Walk_down, 's')
tt.onkeypress(Middle, 'm')
tt.onkeypress(Change_color, 'c')
tt.onkeypress(Pen_color, 'p')
tt.onkeypress(Hide_turtle, 'h')
tt.onkeypress(Show_turtle, 'H')
tt.onkeypress(Exit, 'q')
# tt.onkeypress(Save_image, 'k')
tt.update()
tt.done()
# Need Update
"""
1. Saving Canvas
2. Change Turtle Walk Move in running Program
3. Change Title in Running Program
4. Fill Color Live
5. Auto Round Shape
"""