-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovimiento.py
120 lines (100 loc) · 1.97 KB
/
movimiento.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# reference: https://www.geeksforgeeks.org/turtle-programming-python/
# import
import turtle
# declarate library
t = turtle.Pen()
def dibujo(forma="turtle", posicion=90) :
# change logo
t.shape(forma) # “arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”
def avanzar(pasos) :
t.forward(pasos)
def retroceder(pasos) :
t.back(pasos)
def derecha(grados) :
t.right(grados)
def izquierda(grados) :
t.left(grados)
def mover(x,y):
t.up()
t.goto(x,y)
t.down()
def circulo(rad) :
t.circle(rad)
def triangulo(side):
for i in range(3):
avanzar(side)
izquierda(120)
def fin() :
# prevent to close the screen
t.getscreen()._root.mainloop()
# Finish by turtle.done() command
turtle.done()
# set movements
def comenzar() :
# H
mover(-400,50)
avanzar(200)
derecha(90)
avanzar(90)
derecha(90)
avanzar(200)
izquierda(90)
avanzar(90)
izquierda(90)
avanzar(200)
derecha(90)
avanzar(90)
derecha(90)
avanzar(400)
derecha(90)
avanzar(90)
derecha(90)
avanzar(160)
izquierda(90)
avanzar(90)
izquierda(90)
avanzar(160)
derecha(90)
avanzar(90)
derecha(90)
avanzar(200)
# O
mover(150,-10)
dibujo('circle')
circulo(130)
mover(130,-25)
dibujo('square')
circulo(80)
# L
mover(170,-145)
avanzar(200)
derecha(90)
avanzar(60)
derecha(90)
avanzar(150)
izquierda(90)
avanzar(60)
derecha(90)
avanzar(50)
derecha(90)
avanzar(120)
# A
mover(380,-15)
dibujo('triangle')
izquierda(60)
triangulo(150)
mover(350,-120)
izquierda(120)
triangulo(80)
dibujo('turtle')
mover(350,350)
def inicio(bgColor="white", title="Turtle") :
tut = turtle.Screen()
tut.bgcolor(bgColor)
tut.title(title)
t.setheading(90) # 90 center
mover(0,100)
dibujo()
inicio("green")
comenzar()
fin()