{"id":818414,"student_id":10,"content":"from game import *\nfrom random import *\n\nset_backdrop('bg.png') #設定背景\nlevel = create_sprite(['l_' + str(i) + '.png' for i in range(11)]) #進度條\nn1 = create_sprite([str(i) + '.png' for i in range(10)]) #時間十位數\nn2 = create_sprite([str(i) + '.png' for i in range(10)]) #時間個位數\nrules = create_sprite('rules.png') #遊戲說明\n# create_sound('bgm.ogg', True)\nlevel.move_to(600, 800)\nn1.move_to(570, 90)\nn2.move_to(630, 90)\nrules.layer = 1\n# rules.hidden = True\n\nlevel.costume_id = 5\n\n#數字置換表\ntable = [[8],[7],[],[9],[],[6, 9],[8, 5],[1],[0, 6, 9],[3, 5, 8]]\n\n#七段顯示器對應顯示\nshapes = ['1111110', '0110000', '1101101', '1111001', '0110011', '1011011', '1011111', '1110000', '1111111', '1111011']\n\n#七段顯示器角色座標與方向\npos = [\n { \"x\": 200, \"y\": 250, \"d\": 0 },\n { \"x\": 300, \"y\": 350, \"d\": 90 },\n { \"x\": 300, \"y\": 550, \"d\": 90 },\n { \"x\": 200, \"y\": 650, \"d\": 0 },\n { \"x\": 100, \"y\": 550, \"d\": 90 },\n { \"x\": 100, \"y\": 350, \"d\": 90 },\n { \"x\": 200, \"y\": 450, \"d\": 0 },\n]\n \nclock = 100 * 60 #剩餘時間\ndelay = -1 #重置關卡倒數\nnums = [] #儲存所有叩叮角色\n\n#創造叩叮\nfor i in range(3):\n for p in pos:\n s = create_sprite('k_0.png', 'k_1.png', 'k_2.png', 'k_3.png', 'k_4.png', 'k_5.png')\n s.x = p['x'] + i * 400\n s.y = p['y']\n s.direction = p['d']\n nums.append(s)\n\n#載入下個關卡\ndef next_level():\n a = randrange(10)\n b = randrange(10 - a)\n c = a + b\n \n print(a, b, c) #印出答案幫助檢查\n \n # 置換數字\n rand = randrange(3)\n if a != 2 and a != 4 and rand == 0: a = choice(table[a])\n elif b != 2 and b != 4 and rand == 1: b = choice(table[b])\n elif c != 2 and c != 4 and rand == 2: c = choice(table[c])\n else: return next_level()\n \n # 將數字更新至角色上\n s = shapes[a] + shapes[b] + shapes[c]\n for i in range(21):\n nums[i].costume_id = randrange(5)\n if s[i] == '0': nums[i].opacity = 0.1\n if s[i] == '1': nums[i].opacity = 1\n \n#遊戲迴圈\ndef loop():\n global clock, delay\n \n if key.space: rules.hidden = True #按下空白鍵隱藏說明\n \n if rules.hidden: delay -= 1 #關卡切換特效倒數\n for s in nums:\n if delay \u003e= 11 and delay \u003c= 20:\n s.scale -= 0.1 #數到 11-20 時縮小\n if delay \u003e= 0 and delay \u003c= 9: \n s.scale += 0.1 #數到 0-9 時放大\n if delay == 10: next_level() #數到 10 時產生新的關卡\n \n if rules.hidden: clock -= 1\n n1.costume_id = (clock // 60) // 10 #十位數\n n2.costume_id = (clock // 60) % 10 #個位數\n \n #如果 10 關全破或時間到就停止遊戲\n if level.costume_id == 10 or clock == 0: stop()\n \n#當畫面點擊\ndef onclick():\n global delay\n for s in nums:\n if s.touched(cursor):\n s.opacity = 0.1 if s.opacity == 1 else 1\n \n a = toDigit(nums[0:7]) #取出前面 7 個角色\n b = toDigit(nums[7:14]) #取中間 7 個角色\n c = toDigit(nums[14:21]) #取出後前 7 個角色\n if a != -1 or b != -1 or c != -1: #確認符合數字形狀\n if a + b == c and delay \u003c 0: #確認公式正確\n level.costume_id += 1 #進度條切換下一張\n delay = 60 #設定切換關卡倒數時間\n # create_sound('win.wav')\n\n#七段顯示器轉換回數字\ndef toDigit(arr):\n s = ''\n for a in arr:\n if a.opacity == 1: s += '1'\n else: s += '0'\n for i in range(10):\n if shapes[i] == s: return i\n return -1 #如果形狀不符合數字就回傳 -1\n\non('click', onclick) #當畫面點擊\nforever(loop) #不斷執行遊戲迴圈\nnext_level() #產生關卡\non('keydown', 'space', next_level) #測試使用\n","created_at":"2024-08-14T15:45:56.953+08:00","updated_at":"2024-11-14T14:44:04.963+08:00","name":"間諜加加九_預設版 (1)","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/818414/44cc6c03d0ef4da5931426fcc2d18176.jpg"},"parent_id":818037,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":31,"hashid":"qmdsvvdq3","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18059015,"file_name":"l_0.png","project_id":818414,"asset_id":765408,"created_at":"2024-08-15T15:40:03.099+08:00","updated_at":"2024-08-15T15:40:03.099+08:00"},{"id":18059016,"file_name":"l_1.png","project_id":818414,"asset_id":765409,"created_at":"2024-08-15T15:40:03.103+08:00","updated_at":"2024-08-15T15:40:03.103+08:00"},{"id":18059017,"file_name":"bg.png","project_id":818414,"asset_id":765410,"created_at":"2024-08-15T15:40:03.107+08:00","updated_at":"2024-08-15T15:40:03.107+08:00"},{"id":18059018,"file_name":"win.wav","project_id":818414,"asset_id":765411,"created_at":"2024-08-15T15:40:03.118+08:00","updated_at":"2024-08-15T15:40:03.118+08:00"},{"id":18059019,"file_name":"bgm.ogg","project_id":818414,"asset_id":765412,"created_at":"2024-08-15T15:40:03.173+08:00","updated_at":"2024-08-15T15:40:03.173+08:00"},{"id":18059020,"file_name":"k_4.png","project_id":818414,"asset_id":765413,"created_at":"2024-08-15T15:40:03.177+08:00","updated_at":"2024-08-15T15:40:03.177+08:00"},{"id":18059021,"file_name":"k_5.png","project_id":818414,"asset_id":765414,"created_at":"2024-08-15T15:40:03.181+08:00","updated_at":"2024-08-15T15:40:03.181+08:00"},{"id":18059022,"file_name":"rules.png","project_id":818414,"asset_id":765415,"created_at":"2024-08-15T15:40:03.186+08:00","updated_at":"2024-08-15T15:40:03.186+08:00"},{"id":18059023,"file_name":"0.png","project_id":818414,"asset_id":765416,"created_at":"2024-08-15T15:40:03.191+08:00","updated_at":"2024-08-15T15:40:03.191+08:00"},{"id":18059024,"file_name":"1.png","project_id":818414,"asset_id":765417,"created_at":"2024-08-15T15:40:03.195+08:00","updated_at":"2024-08-15T15:40:03.195+08:00"},{"id":18059025,"file_name":"2.png","project_id":818414,"asset_id":765418,"created_at":"2024-08-15T15:40:03.198+08:00","updated_at":"2024-08-15T15:40:03.198+08:00"},{"id":18059026,"file_name":"3.png","project_id":818414,"asset_id":765419,"created_at":"2024-08-15T15:40:03.203+08:00","updated_at":"2024-08-15T15:40:03.203+08:00"},{"id":18059027,"file_name":"6.png","project_id":818414,"asset_id":765420,"created_at":"2024-08-15T15:40:03.207+08:00","updated_at":"2024-08-15T15:40:03.207+08:00"},{"id":18059028,"file_name":"7.png","project_id":818414,"asset_id":765421,"created_at":"2024-08-15T15:40:03.210+08:00","updated_at":"2024-08-15T15:40:03.210+08:00"},{"id":18059029,"file_name":"l_4.png","project_id":818414,"asset_id":765422,"created_at":"2024-08-15T15:40:03.215+08:00","updated_at":"2024-08-15T15:40:03.215+08:00"},{"id":18059030,"file_name":"l_5.png","project_id":818414,"asset_id":765423,"created_at":"2024-08-15T15:40:03.219+08:00","updated_at":"2024-08-15T15:40:03.219+08:00"},{"id":18059031,"file_name":"l_10.png","project_id":818414,"asset_id":765424,"created_at":"2024-08-15T15:40:03.223+08:00","updated_at":"2024-08-15T15:40:03.223+08:00"},{"id":18059032,"file_name":"l_6.png","project_id":818414,"asset_id":765425,"created_at":"2024-08-15T15:40:03.227+08:00","updated_at":"2024-08-15T15:40:03.227+08:00"},{"id":18059033,"file_name":"l_7.png","project_id":818414,"asset_id":765426,"created_at":"2024-08-15T15:40:03.231+08:00","updated_at":"2024-08-15T15:40:03.231+08:00"},{"id":18059034,"file_name":"4.png","project_id":818414,"asset_id":765427,"created_at":"2024-08-15T15:40:03.235+08:00","updated_at":"2024-08-15T15:40:03.235+08:00"},{"id":18059035,"file_name":"5.png","project_id":818414,"asset_id":765428,"created_at":"2024-08-15T15:40:03.238+08:00","updated_at":"2024-08-15T15:40:03.238+08:00"},{"id":18059036,"file_name":"l_8.png","project_id":818414,"asset_id":765429,"created_at":"2024-08-15T15:40:03.242+08:00","updated_at":"2024-08-15T15:40:03.242+08:00"},{"id":18059037,"file_name":"l_9.png","project_id":818414,"asset_id":765430,"created_at":"2024-08-15T15:40:03.266+08:00","updated_at":"2024-08-15T15:40:03.266+08:00"},{"id":18059038,"file_name":"k_2.png","project_id":818414,"asset_id":765431,"created_at":"2024-08-15T15:40:03.270+08:00","updated_at":"2024-08-15T15:40:03.270+08:00"},{"id":18059039,"file_name":"k_3.png","project_id":818414,"asset_id":765432,"created_at":"2024-08-15T15:40:03.273+08:00","updated_at":"2024-08-15T15:40:03.273+08:00"},{"id":18059040,"file_name":"8.png","project_id":818414,"asset_id":765433,"created_at":"2024-08-15T15:40:03.277+08:00","updated_at":"2024-08-15T15:40:03.277+08:00"},{"id":18059041,"file_name":"9.png","project_id":818414,"asset_id":765434,"created_at":"2024-08-15T15:40:03.280+08:00","updated_at":"2024-08-15T15:40:03.280+08:00"},{"id":18059042,"file_name":"k_0.png","project_id":818414,"asset_id":765435,"created_at":"2024-08-15T15:40:03.284+08:00","updated_at":"2024-08-15T15:40:03.284+08:00"},{"id":18059043,"file_name":"k_1.png","project_id":818414,"asset_id":765436,"created_at":"2024-08-15T15:40:03.287+08:00","updated_at":"2024-08-15T15:40:03.287+08:00"},{"id":18059044,"file_name":"l_2.png","project_id":818414,"asset_id":765437,"created_at":"2024-08-15T15:40:03.296+08:00","updated_at":"2024-08-15T15:40:03.296+08:00"},{"id":18059045,"file_name":"l_3.png","project_id":818414,"asset_id":765438,"created_at":"2024-08-15T15:40:03.301+08:00","updated_at":"2024-08-15T15:40:03.301+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦