-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTrain.py
333 lines (309 loc) · 6.82 KB
/
Train.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File: Train.py
# Description: File that uses turtle library to draw a train
# Student Name: Braeden Conrad
# Student UT EID: bsc875
# Course Name: CS 313E
# Unique Number: 51335
# Date Created: 02/11/18
# Date Last Modified: 02/11/18
import turtle
def draw_spokes(x,y,R,r,ttl):
ttl.penup()
ttl.goto(x,y) #go to center
ttl.setheading(10)
ttl.forward(r)
ttl.pendown()
ttl.forward(R-r)
ttl.penup()
ttl.goto(x,y)
for i in range(7):
ttl.left(45)
ttl.penup()
ttl.forward(r)
ttl.pendown()
ttl.forward(R-r)
ttl.penup()
ttl.goto(x,y)
ttl.right(10)
ttl.penup()
ttl.forward(r)
ttl.pendown()
ttl.forward(R-r)
ttl.penup()
ttl.goto(x,y)
for i in range(7):
ttl.right(45)
ttl.penup()
ttl.forward(r)
ttl.pendown()
ttl.forward(R-r)
ttl.penup()
ttl.goto(x,y)
ttl.penup()
def main():
# put the label
turtle.title("Braeden's Train")
# setup screen size
turtle.setup(800, 800, 0, 0)
ttl = turtle.Turtle()
# draw the track
# draw the top line
ttl.penup()
ttl.goto(-200,-200)
ttl.pendown()
ttl.goto(200,-200)
# draw bottom part
ttl.penup()
ttl.goto(-200,-210)
ttl.pendown()
ttl.goto(200,-210)
ttl.penup()
ttl.goto(-200,-210)
ttl.setheading(0)
turtle.forward(10)
for i in range (13):
ttl.pendown()
ttl.setheading(270)
ttl.forward(5)
ttl.setheading(0)
ttl.forward(10)
ttl.setheading(90)
ttl.forward(5)
ttl.penup()
ttl.setheading(0)
ttl.forward(22)
#draw bottom frame of train
ttl.penup()
ttl.color('blue')
ttl.goto(-175,-160)
ttl.setheading(0)
ttl.pendown()
ttl.forward(10)
ttl.left(90)
ttl.circle(-40,180)
ttl.setheading(0)
ttl.forward(40)
ttl.left(90)
ttl.circle(-40,180)
ttl.setheading(0)
ttl.forward(30)
ttl.left(90)
ttl.circle(-40,180)
ttl.setheading(0)
ttl.forward(15)
# draw the wheels
ttl.color('red')
# wheel 1
ttl.penup()
ttl.goto(-160,-165)
ttl.setheading(90)
ttl.pendown()
ttl.circle(-35,360)
ttl.setheading(0) #inner circle
ttl.penup()
ttl.forward(5)
ttl.pendown()
ttl.setheading(90)
ttl.circle(-30,360)
ttl.setheading(0)
ttl.penup()
ttl.forward(25)
ttl.pendown()
ttl.setheading(90)
ttl.circle(-5,360) #small 2nd inner circle
draw_spokes(-125,-165,30,5,ttl)
# wheel 2
ttl.penup()
ttl.goto(-35,-170)
ttl.setheading(90)
ttl.pendown()
ttl.circle(-30,360)
ttl.penup()
ttl.setheading(0)
ttl.forward(5)
ttl.pendown()
ttl.setheading(90)
ttl.circle(-25,360)
ttl.setheading(0)
ttl.penup()
ttl.forward(20)
ttl.pendown()
ttl.setheading(90)
ttl.circle(-5,360) #small 2nd inner circle
draw_spokes(-5,-170,25,5,ttl)
#wheel3
ttl.penup()
ttl.goto(75,-170)
ttl.setheading(90)
ttl.pendown()
ttl.circle(-30,360)
ttl.penup()
ttl.setheading(0)
ttl.forward(5)
ttl.pendown()
ttl.setheading(90)
ttl.circle(-25,360)
ttl.setheading(0)
ttl.penup()
ttl.forward(20)
ttl.pendown()
ttl.setheading(90)
ttl.circle(-5,360) #small 2nd inner circle
draw_spokes(105,-170,25,5,ttl)
#outer frame
ttl.color('blue')
ttl.penup()
ttl.goto(-175,-160)
ttl.setheading(90)
ttl.pendown()
ttl.goto(-175,30)
ttl.penup()
ttl.goto(-70,-160)
ttl.pendown()
ttl.goto(-70,30)
#rectangle on top
ttl.setheading(0)
ttl.forward(10)
ttl.left(90)
ttl.forward(5)
ttl.goto(-185,35)
ttl.goto(-185,30)
ttl.goto(-65,30)
#continue outer part
ttl.penup()
ttl.goto(-70,-20)
ttl.pendown()
ttl.goto(160,-20)
ttl.goto(160,-175)
#front of train
ttl.goto(190,-175) #bottom line on the train
ttl.setheading(105)
ttl.forward(40)
ttl.setheading(180)
ttl.setx(160) #or forward 22
ttl.penup()
#rectangles
ttl.goto(160,-20)
ttl.goto(160,-30)
ttl.pendown()
#big recangle
ttl.goto(170,-30)
ttl.goto(170,-120)
ttl.goto(160,-120)
#small rectangle
ttl.penup()
ttl.goto(170,-60)
ttl.pendown()
ttl.goto(175,-60)
ttl.goto(175,-90)
ttl.goto(170,-90)
#windows
ttl.penup()
ttl.goto(-155,20)
#left
ttl.pendown()
ttl.begin_fill()
ttl.color('gray')
ttl.goto(-130,20)
ttl.goto(-130,-20)
ttl.goto(-155,-20)
ttl.goto(-155,20)
ttl.end_fill()
ttl.color('blue')
ttl.goto(-130,20)
ttl.goto(-130,-20)
ttl.goto(-155,-20)
ttl.goto(-155,20)
#right
ttl.penup()
ttl.goto(-70,30) #right corner
ttl.goto(-90,20)
ttl.pendown()
ttl.begin_fill()
ttl.color('gray')
ttl.goto(-115,20)
ttl.goto(-115,-20)
ttl.goto(-90,-20)
ttl.goto(-90,20)
ttl.end_fill()
ttl.color('blue')
ttl.goto(-115,20)
ttl.goto(-115,-20)
ttl.goto(-90,-20)
ttl.goto(-90,20)
#top rectangles
ttl.penup()
ttl.goto(25,-20)
ttl.pendown()
ttl.goto(25,-10)
ttl.goto(45,-10)
ttl.goto(45,-20)
ttl.penup()
ttl.goto(30,-10)
ttl.pendown()
ttl.goto(30,-5)
ttl.goto(40,-5)
ttl.goto(40,-10)
#smoke thing
ttl.penup()
ttl.goto(100,-20)
ttl.pendown()
ttl.goto(90,40)
ttl.penup()
ttl.goto(115,-20)
ttl.pendown()
ttl.goto(125,40)
ttl.goto(90,40)
ttl.goto(95,45)
ttl.penup()
ttl.goto(125,40)
ttl.pendown()
ttl.goto(120,45)
ttl.goto(95,45)
# add in the dot part
ttl.penup()
ttl.goto(20,-20)
ttl.pendown()
ttl.goto(20,-100)
ttl.goto(15,-100)
ttl.goto(15,-20)
ttl.penup()
ttl.goto(17.5,-20)
y = -20
for i in range (16):
y-=5
ttl.pendown()
ttl.dot(3,'black')
ttl.penup()
ttl.goto(17.5,y)
ttl.penup()
ttl.goto(-70,-100)
ttl.pendown()
ttl.goto(160,-100)
ttl.goto(160,-105)
ttl.goto(-70,-105)
ttl.penup()
ttl.goto(-70,-102.5)
x = -70
for i in range (48):
x+=5
ttl.pendown()
ttl.dot(3,'black')
ttl.penup()
ttl.goto(x,-102.5)
ttl.goto(105,-20)
ttl.pendown()
ttl.goto(105,-100)
ttl.goto(110,-100)
ttl.goto(110,-20)
ttl.penup()
ttl.goto(107.5,-20)
y = -20
for i in range (16):
y-=5
ttl.pendown()
ttl.dot(3,'black')
ttl.penup()
ttl.goto(107.5,y)
turtle.done()
main()