{"id":884450,"student_id":10,"content":"from game import *\nfrom random import *\n\nH = 8 #高幾個國旗\nW = 12 #寬幾個國旗\nset_backdrop('bg.png')\nimgs = [str(i) + '.png' for i in range(32)]\nnums = ['n' + str(i) + '.png' for i in range(10)]\nrules = create_sprite('rules.png', 'end.png')\nrules.layer = 1\ncreate_sound('bgm.wav', True)\npoint = create_sprite('point.png')\n\ntimer = [] #從放時間角色\nlights = [] #存放黃色方塊\nflags = [] #存放國旗角色\nstart = None #存放第一次點擊的國旗角色\nfocus = None\nclock = 0 #紀錄經過多少時間\ncount = 0 #紀錄消除多少個國旗\n\n# 創造時間數字\nfor i in range(4)\n n = create_sprite(nums)\n n.x = 240 * i + 240\n timer.append(n)\n\n# 創造黃色塊\nfor y in range(H + 4):\n for x in range(W + 4):\n l = create_sprite('light.png')\n l.x = x * 75 + 75 * 0.5\n l.y = y * 75 + 75 * 0.5\n lights.append(l)\n\n# 創造國旗\nfor x in range(W):\n for y in range(H):\n f = create_sprite(imgs\n f.x = x * 75 + 75 * 2.5\n f.y = y * 75 + 75 * 2.5\n f.costume_id = (y * W + x) // 2 % 32\n flags.append(f)\n\n# 洗牌\ndef shuffle():\n for i in range(W * H):\n rand = randrange(W * H)\n f1 = flag[i]\n f2 = flag[rand]\n a = f1.costume_id\n b = f2.costume_id\n f1.costume_id = b\n f2.costume_id = a\n \n# 遊戲迴圈\ndef loop():\n global start, focus\n \n for s in lights:\n if not start: #如果沒有點擊第一個國旗\n s.opacity = 0.01 #就全部設定為幾乎透明\n elif s.touched(cursor): #如果碰到滑鼠\n s.opacity = 1 #就讓方塊亮起來\n \n for f in flags:\n if start and f.touched(cursor) and f.costume_id != start.costume_id:\n start = None\n \n update_timer() #更新時間\n \n# 更新時間\ndef update_timer():\n global clock\n if rules.hidden: clock += 1\n s = clock // 60\n timer[0].costume_id = 0\n timer[1].costume_id = 0\n timer[2].costume_id = 0\n timer[3].costume_id = 0\n \n\n# 滑鼠按下 \ndef mousedown():\n global start, focus\n for f in flags:\n if f.touched(cursor):\n start = f\n\n# 滑鼠放開\ndef mouseup():\n global start, count\n for f in flags:\n # 如果已經點了第一個旗子\n # 而且這個旗子碰到滑鼠\n # 而且這個旗子的造型跟第一個旗子一樣\n # 而且這個旗子跟第一個旗子不是同一個角色\n if start and f.touched(cursor) and f.costume_id == start.costume_id and f is not start:\n f.hidden = True #隱藏這個旗子\n start.hidden = True #隱藏第二個旗子\n count += 2\n start = None #清空\n \n if count == W * H: gameover()\n \n# 開始遊戲\ndef startgame():\n rules.hidden = True\n for n in timer + [point]:\n n.x *= 0.1 #縮小至左上角\n n.y *= 0.1 #縮小至左上角\n n.scale *= 0.1 #縮小至左上角\n\n# 遊戲結束\ndef gameover():\n for n in timer + [point]: #將時間放大恢復至場景中央\n n.x *= 10\n n.y *= 10\n n.scale *= 10\n rules.costume_id = 1 #切換結束圖片\n rules.hidden = False #顯示遊戲結束\n stop()\n\non('mousedown', mousedown) #當滑鼠按下時\non('mouseup', mouseup) #當滑鼠放開時\non('keydown', 'space', startgame) #當按下空白鍵開始遊戲\nforever(loop) #重複不斷執行遊戲迴圈\n\n","created_at":"2024-11-13T10:58:00.869+08:00","updated_at":"2024-11-18T18:03:43.182+08:00","name":"國旗配對碰_預設版","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/884450/8bb4d64886ee7f6371623d7ef2022561.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"9ygsr838j","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":34595732,"file_name":"n0.png","project_id":884450,"asset_id":793115,"created_at":"2024-11-18T17:37:34.795+08:00","updated_at":"2024-11-18T17:37:34.795+08:00"},{"id":34595733,"file_name":"n1.png","project_id":884450,"asset_id":793116,"created_at":"2024-11-18T17:37:34.799+08:00","updated_at":"2024-11-18T17:37:34.799+08:00"},{"id":34595734,"file_name":"n2.png","project_id":884450,"asset_id":793117,"created_at":"2024-11-18T17:37:34.803+08:00","updated_at":"2024-11-18T17:37:34.803+08:00"},{"id":34595735,"file_name":"n3.png","project_id":884450,"asset_id":793118,"created_at":"2024-11-18T17:37:34.807+08:00","updated_at":"2024-11-18T17:37:34.807+08:00"},{"id":34595736,"file_name":"n4.png","project_id":884450,"asset_id":793119,"created_at":"2024-11-18T17:37:34.811+08:00","updated_at":"2024-11-18T17:37:34.811+08:00"},{"id":34595737,"file_name":"n5.png","project_id":884450,"asset_id":793120,"created_at":"2024-11-18T17:37:34.815+08:00","updated_at":"2024-11-18T17:37:34.815+08:00"},{"id":34595738,"file_name":"n6.png","project_id":884450,"asset_id":793121,"created_at":"2024-11-18T17:37:34.819+08:00","updated_at":"2024-11-18T17:37:34.819+08:00"},{"id":34595739,"file_name":"n7.png","project_id":884450,"asset_id":793122,"created_at":"2024-11-18T17:37:34.823+08:00","updated_at":"2024-11-18T17:37:34.823+08:00"},{"id":34595740,"file_name":"n8.png","project_id":884450,"asset_id":793123,"created_at":"2024-11-18T17:37:34.827+08:00","updated_at":"2024-11-18T17:37:34.827+08:00"},{"id":34595741,"file_name":"n9.png","project_id":884450,"asset_id":793124,"created_at":"2024-11-18T17:37:34.831+08:00","updated_at":"2024-11-18T17:37:34.831+08:00"},{"id":34595742,"file_name":"bg.png","project_id":884450,"asset_id":793125,"created_at":"2024-11-18T17:37:34.835+08:00","updated_at":"2024-11-18T17:37:34.835+08:00"},{"id":34595743,"file_name":"end.png","project_id":884450,"asset_id":793126,"created_at":"2024-11-18T17:37:34.839+08:00","updated_at":"2024-11-18T17:37:34.839+08:00"},{"id":34595744,"file_name":"rules.png","project_id":884450,"asset_id":793127,"created_at":"2024-11-18T17:37:34.843+08:00","updated_at":"2024-11-18T17:37:34.843+08:00"},{"id":34595745,"file_name":"0.png","project_id":884450,"asset_id":793128,"created_at":"2024-11-18T17:37:34.847+08:00","updated_at":"2024-11-18T17:37:34.847+08:00"},{"id":34595746,"file_name":"1.png","project_id":884450,"asset_id":793129,"created_at":"2024-11-18T17:37:34.851+08:00","updated_at":"2024-11-18T17:37:34.851+08:00"},{"id":34595747,"file_name":"2.png","project_id":884450,"asset_id":793130,"created_at":"2024-11-18T17:37:34.855+08:00","updated_at":"2024-11-18T17:37:34.855+08:00"},{"id":34595748,"file_name":"3.png","project_id":884450,"asset_id":793131,"created_at":"2024-11-18T17:37:34.859+08:00","updated_at":"2024-11-18T17:37:34.859+08:00"},{"id":34595749,"file_name":"4.png","project_id":884450,"asset_id":793132,"created_at":"2024-11-18T17:37:34.863+08:00","updated_at":"2024-11-18T17:37:34.863+08:00"},{"id":34595750,"file_name":"5.png","project_id":884450,"asset_id":793133,"created_at":"2024-11-18T17:37:34.867+08:00","updated_at":"2024-11-18T17:37:34.867+08:00"},{"id":34595751,"file_name":"6.png","project_id":884450,"asset_id":793134,"created_at":"2024-11-18T17:37:34.871+08:00","updated_at":"2024-11-18T17:37:34.871+08:00"},{"id":34595752,"file_name":"7.png","project_id":884450,"asset_id":793135,"created_at":"2024-11-18T17:37:34.874+08:00","updated_at":"2024-11-18T17:37:34.874+08:00"},{"id":34595753,"file_name":"8.png","project_id":884450,"asset_id":793136,"created_at":"2024-11-18T17:37:34.878+08:00","updated_at":"2024-11-18T17:37:34.878+08:00"},{"id":34595754,"file_name":"9.png","project_id":884450,"asset_id":793137,"created_at":"2024-11-18T17:37:34.909+08:00","updated_at":"2024-11-18T17:37:34.909+08:00"},{"id":34595755,"file_name":"10.png","project_id":884450,"asset_id":793138,"created_at":"2024-11-18T17:37:34.913+08:00","updated_at":"2024-11-18T17:37:34.913+08:00"},{"id":34595756,"file_name":"11.png","project_id":884450,"asset_id":793139,"created_at":"2024-11-18T17:37:34.917+08:00","updated_at":"2024-11-18T17:37:34.917+08:00"},{"id":34595757,"file_name":"12.png","project_id":884450,"asset_id":793140,"created_at":"2024-11-18T17:37:34.920+08:00","updated_at":"2024-11-18T17:37:34.920+08:00"},{"id":34595758,"file_name":"13.png","project_id":884450,"asset_id":793141,"created_at":"2024-11-18T17:37:34.924+08:00","updated_at":"2024-11-18T17:37:34.924+08:00"},{"id":34595759,"file_name":"14.png","project_id":884450,"asset_id":793142,"created_at":"2024-11-18T17:37:34.928+08:00","updated_at":"2024-11-18T17:37:34.928+08:00"},{"id":34595760,"file_name":"15.png","project_id":884450,"asset_id":793143,"created_at":"2024-11-18T17:37:34.932+08:00","updated_at":"2024-11-18T17:37:34.932+08:00"},{"id":34595761,"file_name":"16.png","project_id":884450,"asset_id":793144,"created_at":"2024-11-18T17:37:34.936+08:00","updated_at":"2024-11-18T17:37:34.936+08:00"},{"id":34595762,"file_name":"17.png","project_id":884450,"asset_id":793145,"created_at":"2024-11-18T17:37:34.940+08:00","updated_at":"2024-11-18T17:37:34.940+08:00"},{"id":34595763,"file_name":"18.png","project_id":884450,"asset_id":793146,"created_at":"2024-11-18T17:37:34.944+08:00","updated_at":"2024-11-18T17:37:34.944+08:00"},{"id":34595764,"file_name":"19.png","project_id":884450,"asset_id":793147,"created_at":"2024-11-18T17:37:34.948+08:00","updated_at":"2024-11-18T17:37:34.948+08:00"},{"id":34595765,"file_name":"20.png","project_id":884450,"asset_id":793148,"created_at":"2024-11-18T17:37:34.951+08:00","updated_at":"2024-11-18T17:37:34.951+08:00"},{"id":34595766,"file_name":"21.png","project_id":884450,"asset_id":793149,"created_at":"2024-11-18T17:37:34.955+08:00","updated_at":"2024-11-18T17:37:34.955+08:00"},{"id":34595767,"file_name":"22.png","project_id":884450,"asset_id":793150,"created_at":"2024-11-18T17:37:34.959+08:00","updated_at":"2024-11-18T17:37:34.959+08:00"},{"id":34595768,"file_name":"23.png","project_id":884450,"asset_id":793151,"created_at":"2024-11-18T17:37:34.963+08:00","updated_at":"2024-11-18T17:37:34.963+08:00"},{"id":34595769,"file_name":"24.png","project_id":884450,"asset_id":793152,"created_at":"2024-11-18T17:37:34.967+08:00","updated_at":"2024-11-18T17:37:34.967+08:00"},{"id":34595770,"file_name":"25.png","project_id":884450,"asset_id":793153,"created_at":"2024-11-18T17:37:34.971+08:00","updated_at":"2024-11-18T17:37:34.971+08:00"},{"id":34595771,"file_name":"26.png","project_id":884450,"asset_id":793154,"created_at":"2024-11-18T17:37:34.975+08:00","updated_at":"2024-11-18T17:37:34.975+08:00"},{"id":34595772,"file_name":"27.png","project_id":884450,"asset_id":793155,"created_at":"2024-11-18T17:37:34.979+08:00","updated_at":"2024-11-18T17:37:34.979+08:00"},{"id":34595773,"file_name":"28.png","project_id":884450,"asset_id":793156,"created_at":"2024-11-18T17:37:34.983+08:00","updated_at":"2024-11-18T17:37:34.983+08:00"},{"id":34595774,"file_name":"29.png","project_id":884450,"asset_id":793157,"created_at":"2024-11-18T17:37:34.987+08:00","updated_at":"2024-11-18T17:37:34.987+08:00"},{"id":34595775,"file_name":"30.png","project_id":884450,"asset_id":793158,"created_at":"2024-11-18T17:37:34.992+08:00","updated_at":"2024-11-18T17:37:34.992+08:00"},{"id":34595776,"file_name":"31.png","project_id":884450,"asset_id":793159,"created_at":"2024-11-18T17:37:35.005+08:00","updated_at":"2024-11-18T17:37:35.005+08:00"},{"id":34595777,"file_name":"32.png","project_id":884450,"asset_id":793160,"created_at":"2024-11-18T17:37:35.010+08:00","updated_at":"2024-11-18T17:37:35.010+08:00"},{"id":34595778,"file_name":"33.png","project_id":884450,"asset_id":793161,"created_at":"2024-11-18T17:37:35.014+08:00","updated_at":"2024-11-18T17:37:35.014+08:00"},{"id":34595779,"file_name":"34.png","project_id":884450,"asset_id":793162,"created_at":"2024-11-18T17:37:35.019+08:00","updated_at":"2024-11-18T17:37:35.019+08:00"},{"id":34595780,"file_name":"35.png","project_id":884450,"asset_id":793163,"created_at":"2024-11-18T17:37:35.023+08:00","updated_at":"2024-11-18T17:37:35.023+08:00"},{"id":34595781,"file_name":"36.png","project_id":884450,"asset_id":793164,"created_at":"2024-11-18T17:37:35.027+08:00","updated_at":"2024-11-18T17:37:35.027+08:00"},{"id":34595782,"file_name":"37.png","project_id":884450,"asset_id":793165,"created_at":"2024-11-18T17:37:35.031+08:00","updated_at":"2024-11-18T17:37:35.031+08:00"},{"id":34595783,"file_name":"38.png","project_id":884450,"asset_id":793166,"created_at":"2024-11-18T17:37:35.035+08:00","updated_at":"2024-11-18T17:37:35.035+08:00"},{"id":34595784,"file_name":"39.png","project_id":884450,"asset_id":793167,"created_at":"2024-11-18T17:37:35.039+08:00","updated_at":"2024-11-18T17:37:35.039+08:00"},{"id":34595785,"file_name":"40.png","project_id":884450,"asset_id":793168,"created_at":"2024-11-18T17:37:35.043+08:00","updated_at":"2024-11-18T17:37:35.043+08:00"},{"id":34595786,"file_name":"41.png","project_id":884450,"asset_id":793169,"created_at":"2024-11-18T17:37:35.065+08:00","updated_at":"2024-11-18T17:37:35.065+08:00"},{"id":34595787,"file_name":"42.png","project_id":884450,"asset_id":793170,"created_at":"2024-11-18T17:37:35.070+08:00","updated_at":"2024-11-18T17:37:35.070+08:00"},{"id":34595788,"file_name":"43.png","project_id":884450,"asset_id":793171,"created_at":"2024-11-18T17:37:35.074+08:00","updated_at":"2024-11-18T17:37:35.074+08:00"},{"id":34595789,"file_name":"44.png","project_id":884450,"asset_id":793172,"created_at":"2024-11-18T17:37:35.078+08:00","updated_at":"2024-11-18T17:37:35.078+08:00"},{"id":34595790,"file_name":"45.png","project_id":884450,"asset_id":793173,"created_at":"2024-11-18T17:37:35.082+08:00","updated_at":"2024-11-18T17:37:35.082+08:00"},{"id":34595791,"file_name":"46.png","project_id":884450,"asset_id":793174,"created_at":"2024-11-18T17:37:35.086+08:00","updated_at":"2024-11-18T17:37:35.086+08:00"},{"id":34595792,"file_name":"47.png","project_id":884450,"asset_id":793175,"created_at":"2024-11-18T17:37:35.090+08:00","updated_at":"2024-11-18T17:37:35.090+08:00"},{"id":34595793,"file_name":"48.png","project_id":884450,"asset_id":793176,"created_at":"2024-11-18T17:37:35.094+08:00","updated_at":"2024-11-18T17:37:35.094+08:00"},{"id":34595794,"file_name":"49.png","project_id":884450,"asset_id":793177,"created_at":"2024-11-18T17:37:35.098+08:00","updated_at":"2024-11-18T17:37:35.098+08:00"},{"id":34595795,"file_name":"50.png","project_id":884450,"asset_id":793178,"created_at":"2024-11-18T17:37:35.102+08:00","updated_at":"2024-11-18T17:37:35.102+08:00"},{"id":34595796,"file_name":"51.png","project_id":884450,"asset_id":793179,"created_at":"2024-11-18T17:37:35.106+08:00","updated_at":"2024-11-18T17:37:35.106+08:00"},{"id":34595797,"file_name":"52.png","project_id":884450,"asset_id":793180,"created_at":"2024-11-18T17:37:35.110+08:00","updated_at":"2024-11-18T17:37:35.110+08:00"},{"id":34595798,"file_name":"53.png","project_id":884450,"asset_id":793181,"created_at":"2024-11-18T17:37:35.114+08:00","updated_at":"2024-11-18T17:37:35.114+08:00"},{"id":34595799,"file_name":"54.png","project_id":884450,"asset_id":793182,"created_at":"2024-11-18T17:37:35.118+08:00","updated_at":"2024-11-18T17:37:35.118+08:00"},{"id":34595800,"file_name":"55.png","project_id":884450,"asset_id":793183,"created_at":"2024-11-18T17:37:35.122+08:00","updated_at":"2024-11-18T17:37:35.122+08:00"},{"id":34595801,"file_name":"56.png","project_id":884450,"asset_id":793184,"created_at":"2024-11-18T17:37:35.126+08:00","updated_at":"2024-11-18T17:37:35.126+08:00"},{"id":34595802,"file_name":"57.png","project_id":884450,"asset_id":793185,"created_at":"2024-11-18T17:37:35.130+08:00","updated_at":"2024-11-18T17:37:35.130+08:00"},{"id":34595803,"file_name":"58.png","project_id":884450,"asset_id":793186,"created_at":"2024-11-18T17:37:35.134+08:00","updated_at":"2024-11-18T17:37:35.134+08:00"},{"id":34595804,"file_name":"59.png","project_id":884450,"asset_id":793187,"created_at":"2024-11-18T17:37:35.138+08:00","updated_at":"2024-11-18T17:37:35.138+08:00"},{"id":34595805,"file_name":"60.png","project_id":884450,"asset_id":793188,"created_at":"2024-11-18T17:37:35.142+08:00","updated_at":"2024-11-18T17:37:35.142+08:00"},{"id":34595806,"file_name":"61.png","project_id":884450,"asset_id":793189,"created_at":"2024-11-18T17:37:35.146+08:00","updated_at":"2024-11-18T17:37:35.146+08:00"},{"id":34595807,"file_name":"62.png","project_id":884450,"asset_id":793190,"created_at":"2024-11-18T17:37:35.150+08:00","updated_at":"2024-11-18T17:37:35.150+08:00"},{"id":34595808,"file_name":"63.png","project_id":884450,"asset_id":793191,"created_at":"2024-11-18T17:37:35.154+08:00","updated_at":"2024-11-18T17:37:35.154+08:00"},{"id":34595809,"file_name":"light.png","project_id":884450,"asset_id":793192,"created_at":"2024-11-18T17:37:35.159+08:00","updated_at":"2024-11-18T17:37:35.159+08:00"},{"id":34595810,"file_name":"bgm.wav","project_id":884450,"asset_id":793193,"created_at":"2024-11-18T17:37:35.300+08:00","updated_at":"2024-11-18T17:37:35.300+08:00"},{"id":34595811,"file_name":"point.png","project_id":884450,"asset_id":793194,"created_at":"2024-11-18T17:37:35.307+08:00","updated_at":"2024-11-18T17:37:35.307+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦