-
Notifications
You must be signed in to change notification settings - Fork 106
/
week2.py
429 lines (356 loc) · 12.1 KB
/
week2.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# 開始透過 ggame 程式庫進行網際繪圖
# ggame 手冊
# http://brythonserver.github.io/ggame/
'''
from ggame import App, Color, LineStyle, Sprite
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset
# Three primary colors with no transparency (alpha = 1.0)
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(1, black)
# A graphics asset that represents a rectangle
rectangle = RectangleAsset(50, 20, thinline, blue)
# Now display a rectangle
Sprite(rectangle)
myapp = App()
myapp.run()
'''
'''
###############################################
from ggame import App, ImageAsset, Sprite
# Create a displayed object at 0,0 using an image asset
Sprite(ImageAsset("ggame/bunny.jpg"), (0,0))
# Create the app, with a 500x500 pixel stage
app = App(500,500)
# Run the app
app.run()
'''
'''
###############################################
from ggame import App, Color, LineStyle, Sprite
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset
# Three primary colors with no transparency (alpha = 1.0)
white = Color(0xE3E3E3, 1.0)
yellow = Color(0xEDF55F, 1.0)
blue = Color(0x0000FF, 1.0)
green = Color(0x84F564, 1.0)
black = Color(0x4D4843, 1.0)
# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(1, black)
# A graphics asset that represents a rectangle
rectangle = RectangleAsset(400, 200, thinline, green)
ellipse = EllipseAsset(30, 30, thinline, yellow)
ellipse2 = EllipseAsset(70, 40, thinline, blue)
polygon = PolygonAsset([(-85, 100), (25, -75), (100, 125), (-85, 100)], thinline, black)
polygon2 = PolygonAsset([(100, 100), (225, -125), (350, 125), (100, 100)], thinline, black)
# Now display a rectangle
Sprite(rectangle, (100, 200))
Sprite(ellipse, (75, 40))
Sprite(ellipse2, (325, 325))
Sprite(polygon, (150, 150))
Sprite(polygon2, (150, 150))
myapp = App()
myapp.run()
'''
#############################################
"""
picture.py
Author: <Hayden Hatfield>
Credit: <list sources used, if any>
Assignment:Picture
Use the ggame library to "paint" a graphical picture of something (e.g. a house, a face or landscape).
Use at least:
1. Three different Color objects.
2. Ten different Sprite objects.
3. One (or more) RectangleAsset objects.
4. One (or more) CircleAsset objects.
5. One (or more) EllipseAsset objects.
6. One (or more) PolygonAsset objects.
See:
https://github.com/HHS-IntroProgramming/Standards-and-Syllabus/wiki/Displaying-Graphics
for general information on how to use ggame.
See:
http://brythonserver.github.io/ggame/
for detailed information on ggame.
"""
'''
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset
# add your code here \/ \/ \/
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
darkgreen = Color(0x0e270f, 1.0)
nightsky = Color(0x16152b, 1.0)
ground = Color(0x06471a, 1.0)
wood = Color(0x542a0c, 1.0)
moonwhite = Color(0xfff3aa, 1.0)
grey = Color(0x818181, 1.0)
line = LineStyle(2, black)
trunk = RectangleAsset( 20, 50, line, wood )
tri13 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri14 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri15 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri16 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
trunk = RectangleAsset( 20, 50, line, wood )
tri9 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri10 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri11 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri12 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
trunk = RectangleAsset( 20, 50, line, wood )
tri5 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri6 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri7 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri8 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
trunk = RectangleAsset( 20, 50, line, wood )
tri1 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri2 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri3 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
tri4 = PolygonAsset([(0,100),(200,100),(100,0)], line, darkgreen )
moon = EllipseAsset(40, 40, line, moonwhite )
rock = CircleAsset(75, line, grey)
background = RectangleAsset( 1000, 1000, line, nightsky )
ground = RectangleAsset( 1000, 100, line, ground )
Sprite(background, (0, 0))
Sprite(tri9, (450, 575))
Sprite(tri10, (450, 525))
Sprite(tri11, (450, 475))
Sprite(tri12, (450, 425))
Sprite(trunk, (540, 675))
Sprite(tri13, (250, 550))
Sprite(tri14, (250, 500))
Sprite(tri15, (250, 450))
Sprite(tri16, (250, 400))
Sprite(trunk, (340, 650))
Sprite(tri5, (150, 575))
Sprite(tri6, (150, 525))
Sprite(tri7, (150, 475))
Sprite(tri8, (150, 425))
Sprite(trunk, (240, 675))
Sprite(tri1, (20, 550))
Sprite(tri2, (20, 500))
Sprite(tri3, (20, 450))
Sprite(tri4, (20, 400))
Sprite(trunk, (110, 650))
Sprite(moon, (900, 50))
Sprite(rock, (925, 700))
Sprite(ground, (0, 700))
# add your code here /\ /\ /\
myapp = App()
myapp.run()
'''
###############################################
"""
picture.py
Author: Payton
Credit: Andreas and colorpicker.com
Assignment:
Use the ggame library to "paint" a graphical picture of something (e.g. a house, a face or landscape).
Use at least:
1. Three different Color objects.
2. Ten different Sprite objects.
3. One (or more) RectangleAsset objects.
4. One (or more) CircleAsset objects.
5. One (or more) EllipseAsset objects.
6. One (or more) PolygonAsset objects.
See:
https://github.com/HHS-IntroProgramming/Standards-and-Syllabus/wiki/Displaying-Graphics
for general information on how to use ggame.
See:
http://brythonserver.github.io/ggame/
for detailed information on ggame.
"""
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset
# add your code here \/ \/ \/
"""
picture.py
Author: <your name here>
Credit: <list sources used, if any>
Assignment:
Use the ggame library to "paint" a graphical picture of something (e.g. a house, a face or landscape).
Use at least:
1. Three different Color objects.
2. Ten different Sprite objects.
3. One (or more) RectangleAsset objects.
4. One (or more) CircleAsset objects.
5. One (or more) EllipseAsset objects.
6. One (or more) PolygonAsset objects.
See:
https://github.com/HHS-IntroProgramming/Standards-and-Syllabus/wiki/Displaying-Graphics
for general information on how to use ggame.
See:
http://brythonserver.github.io/ggame/
for detailed information on ggame.
"""
'''
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset
# add your code here \/ \/ \/
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
teal = Color(0x24B5B5, 1.0)
yellow = Color(0xFFF700, 1.0)
purple = Color(0x6F00FF, 1.0)
orange = Color(0xFF6A00, 1.0)
white = Color(0xFFFFFF, 1.0)
#lines
thinline = LineStyle(1, black)
thickerline = LineStyle(10, green)
greenline = LineStyle(1, green)
redline = LineStyle(1, red)
blueline = LineStyle(1, blue)
tealline = LineStyle(1, teal)
yellowline = LineStyle(1, yellow)
purpleline = LineStyle(1, purple)
orangeline = LineStyle(1, orange)
#shapes
house = RectangleAsset(300, 300, thinline, teal)
grassyhill = CircleAsset(600, greenline, green)
sun = CircleAsset(150, yellowline, yellow)
roof = PolygonAsset([(5,120), (165,1), (335,120)], tealline, purple)
windowa = RectangleAsset(85, 85, thinline, blue)
windowb = RectangleAsset(85, 85, thinline, blue)
windowc = RectangleAsset(85, 85, thinline, blue)
windowd = RectangleAsset(85, 85, thinline, blue)
door = RectangleAsset(70, 90, thinline, red)
knob = CircleAsset(10, thinline, black)
sandyhill = CircleAsset(600, orangeline, orange)
moon = EllipseAsset(150, 150, thinline, white)
#sprites
Sprite(sandyhill, (300, 1100))
Sprite(grassyhill, (680, 1000))
Sprite(house, (520, 240))
Sprite(sun, (1020, 150))
Sprite(roof, (500, 119))
Sprite(windowa, (540, 270))
Sprite(windowb, (720, 270))
Sprite(windowc, (540, 400))
Sprite(windowd, (720, 400))
Sprite(door, (640, 440))
Sprite(knob, (700, 490))
Sprite(moon, (320, 150))
# add your code here /\ /\ /\
myapp = App()
myapp.run()
# add your code here /\ /\ /\
myapp = App()
myapp.run()
'''
##########################################
"""
picture.py
Author: Avery Wallis
Credit: None so far
Assignment:
Use the ggame library to "paint" a graphical picture of something (e.g. a house, a face or landscape).
Use at least:
1. Three different Color objects.
2. Ten different Sprite objects.
3. One (or more) RectangleAsset objects.
4. One (or more) CircleAsset objects.
5. One (or more) EllipseAsset objects.
6. One (or more) PolygonAsset objects.
See:
https://github.com/HHS-IntroProgramming/Standards-and-Syllabus/wiki/Displaying-Graphics
for general information on how to use ggame.
See:
http://brythonserver.github.io/ggame/
for detailed information on ggame.
"""
##################################
'''
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, LineAsset, PolygonAsset
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
orange = Color(0xffa500, 1.0)
skin =Color(0xFCD15B, 1.0)
wall=Color(0xE8E8E8, 1.0)
orange=Color(0xFFa500,1.0)
plat=Color(0xB9BDBB,1.0)
gooy=Color(0xCDF238,1.0)
white=Color(0xFFFFFF,1.0)
darkblue=Color(0x052099,1.0)
thinline= LineStyle(1, black)
thickline= LineStyle(5, black)
thickishline= LineStyle(2.5, black)
noline=LineStyle(0, black)
portalline=LineStyle(1, blue)
portalline2=LineStyle(1, orange)
wall=RectangleAsset(500,500, noline, wall)
blueportal=EllipseAsset(27, 60, noline, blue)
orangeportal=EllipseAsset(27, 60, noline, orange)
innerportal=EllipseAsset(24, 57, noline, white)
exit=CircleAsset(70, thinline, plat)
exit2=CircleAsset(20, thinline, plat)
plat=RectangleAsset(250, 50, noline, plat)
# 決定 x 方向的 delta 與 y 方向的 delta, 這裡為各 300
doorline=LineAsset(300, 300, thinline)
goo=PolygonAsset([(0,500),(800,500),(800,600,),(0,600)],noline,gooy)
Sprite(wall, (400,20))
Sprite(wall, (100,20))
Sprite(exit, (800,100))
Sprite(exit2, (800, 100))
# 決定線的起點
line1 = Sprite(doorline, (0, 0))
Sprite(doorline, (10, 100))
line1.x = 100
Sprite(plat, (100,400))
Sprite(plat, (650, 150))
Sprite(orangeportal, (700,90))
Sprite(innerportal, (700,90))
Sprite(blueportal, (200,340))
Sprite(innerportal, (200,340))
Sprite(goo, (100,0))
myapp = App()
myapp.run()
# 請問, 如何畫方格紙上的線, 每個小方塊為 20 x 20 個 pixels
'''
########################################
'''
from ggame import App, Color, LineStyle, Sprite
from ggame import CircleAsset
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
thinline = LineStyle(1, black)
mycircle = CircleAsset(5, thinline, blue)
xcoordinates = range(100, 600, 10)
# Generate a list of sprites that form a line!
sprites = [Sprite(mycircle, (x, x*0.5 + 100)) for x in xcoordinates]
myapp = App()
myapp.run()
'''
#################################
"""
multiplication-table.py
Author: Hayden Hatfield
Credit: Mr. Denison
Assignment:
Write and submit a Python program that prints a multiplication table. The user
must be able to determine the width and height of the table before it is printed.
The final multiplication table should look like this:
Width of multiplication table: 10
Height of multiplication table: 8
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
"""
Width = input("Width of multiplication table: ")
Height = input("Height of multiplication table: ")
for y in range(1, int(Height)+1 ):
for x in range(1, int(Width)+1 ):
print (y*x, end = " ")
pass
print()