{"id":818037,"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(100, 100)\nn2.move_to(170, 100)\nrules.layer = 1\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\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 s.costume_id = randrange(6)\n nums.append(s)\n\n#載入下個關卡\ndef next_level():\n a = randrange(10)\n b = randrange(10 - a)\n c = a + b\n \n rand = randrange(3)\n if rand == 0 and a != 2 and a != 4:\n a = choice(table[a])\n elif rand == 1 and b != 2 and b != 4:\n b = choice(table[b])\n elif rand == 2 and c != 2 and c != 4:\n c = choice(table[c])\n else:\n return next_level()\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-13T17:59:40.734+08:00","updated_at":"2024-11-14T15:08:23.175+08:00","name":"5_間諜加加九_完整版","language":"python","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/818037/343f367796d1c6809b7a93366047a6ab.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":51,"hashid":"ej9s668je","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":34440276,"file_name":"l_0.png","project_id":818037,"asset_id":791861,"created_at":"2024-11-14T15:08:22.991+08:00","updated_at":"2024-11-14T15:08:22.991+08:00"},{"id":34440277,"file_name":"l_1.png","project_id":818037,"asset_id":791862,"created_at":"2024-11-14T15:08:22.995+08:00","updated_at":"2024-11-14T15:08:22.995+08:00"},{"id":34440278,"file_name":"bg.png","project_id":818037,"asset_id":791863,"created_at":"2024-11-14T15:08:22.999+08:00","updated_at":"2024-11-14T15:08:22.999+08:00"},{"id":34440279,"file_name":"win.wav","project_id":818037,"asset_id":791864,"created_at":"2024-11-14T15:08:23.028+08:00","updated_at":"2024-11-14T15:08:23.028+08:00"},{"id":34440280,"file_name":"bgm.ogg","project_id":818037,"asset_id":791865,"created_at":"2024-11-14T15:08:23.052+08:00","updated_at":"2024-11-14T15:08:23.052+08:00"},{"id":34440281,"file_name":"k_4.png","project_id":818037,"asset_id":791866,"created_at":"2024-11-14T15:08:23.056+08:00","updated_at":"2024-11-14T15:08:23.056+08:00"},{"id":34440282,"file_name":"k_5.png","project_id":818037,"asset_id":791867,"created_at":"2024-11-14T15:08:23.061+08:00","updated_at":"2024-11-14T15:08:23.061+08:00"},{"id":34440284,"file_name":"0.png","project_id":818037,"asset_id":791869,"created_at":"2024-11-14T15:08:23.071+08:00","updated_at":"2024-11-14T15:08:23.071+08:00"},{"id":34440285,"file_name":"1.png","project_id":818037,"asset_id":791870,"created_at":"2024-11-14T15:08:23.075+08:00","updated_at":"2024-11-14T15:08:23.075+08:00"},{"id":34440286,"file_name":"2.png","project_id":818037,"asset_id":791871,"created_at":"2024-11-14T15:08:23.079+08:00","updated_at":"2024-11-14T15:08:23.079+08:00"},{"id":34440287,"file_name":"3.png","project_id":818037,"asset_id":791872,"created_at":"2024-11-14T15:08:23.083+08:00","updated_at":"2024-11-14T15:08:23.083+08:00"},{"id":34440288,"file_name":"6.png","project_id":818037,"asset_id":791873,"created_at":"2024-11-14T15:08:23.087+08:00","updated_at":"2024-11-14T15:08:23.087+08:00"},{"id":34440289,"file_name":"7.png","project_id":818037,"asset_id":791874,"created_at":"2024-11-14T15:08:23.091+08:00","updated_at":"2024-11-14T15:08:23.091+08:00"},{"id":34440290,"file_name":"l_4.png","project_id":818037,"asset_id":791875,"created_at":"2024-11-14T15:08:23.095+08:00","updated_at":"2024-11-14T15:08:23.095+08:00"},{"id":34440291,"file_name":"l_5.png","project_id":818037,"asset_id":791876,"created_at":"2024-11-14T15:08:23.099+08:00","updated_at":"2024-11-14T15:08:23.099+08:00"},{"id":34440292,"file_name":"l_10.png","project_id":818037,"asset_id":791877,"created_at":"2024-11-14T15:08:23.103+08:00","updated_at":"2024-11-14T15:08:23.103+08:00"},{"id":34440293,"file_name":"l_6.png","project_id":818037,"asset_id":791878,"created_at":"2024-11-14T15:08:23.107+08:00","updated_at":"2024-11-14T15:08:23.107+08:00"},{"id":34440294,"file_name":"l_7.png","project_id":818037,"asset_id":791879,"created_at":"2024-11-14T15:08:23.111+08:00","updated_at":"2024-11-14T15:08:23.111+08:00"},{"id":34440295,"file_name":"4.png","project_id":818037,"asset_id":791880,"created_at":"2024-11-14T15:08:23.114+08:00","updated_at":"2024-11-14T15:08:23.114+08:00"},{"id":34440296,"file_name":"5.png","project_id":818037,"asset_id":791881,"created_at":"2024-11-14T15:08:23.118+08:00","updated_at":"2024-11-14T15:08:23.118+08:00"},{"id":34440297,"file_name":"l_8.png","project_id":818037,"asset_id":791882,"created_at":"2024-11-14T15:08:23.122+08:00","updated_at":"2024-11-14T15:08:23.122+08:00"},{"id":34440298,"file_name":"l_9.png","project_id":818037,"asset_id":791883,"created_at":"2024-11-14T15:08:23.126+08:00","updated_at":"2024-11-14T15:08:23.126+08:00"},{"id":34440299,"file_name":"k_2.png","project_id":818037,"asset_id":791884,"created_at":"2024-11-14T15:08:23.129+08:00","updated_at":"2024-11-14T15:08:23.129+08:00"},{"id":34440300,"file_name":"k_3.png","project_id":818037,"asset_id":791885,"created_at":"2024-11-14T15:08:23.133+08:00","updated_at":"2024-11-14T15:08:23.133+08:00"},{"id":34440301,"file_name":"8.png","project_id":818037,"asset_id":791886,"created_at":"2024-11-14T15:08:23.136+08:00","updated_at":"2024-11-14T15:08:23.136+08:00"},{"id":34440302,"file_name":"9.png","project_id":818037,"asset_id":791887,"created_at":"2024-11-14T15:08:23.140+08:00","updated_at":"2024-11-14T15:08:23.140+08:00"},{"id":34440303,"file_name":"k_0.png","project_id":818037,"asset_id":791888,"created_at":"2024-11-14T15:08:23.161+08:00","updated_at":"2024-11-14T15:08:23.161+08:00"},{"id":34440304,"file_name":"k_1.png","project_id":818037,"asset_id":791889,"created_at":"2024-11-14T15:08:23.165+08:00","updated_at":"2024-11-14T15:08:23.165+08:00"},{"id":34440305,"file_name":"l_2.png","project_id":818037,"asset_id":791890,"created_at":"2024-11-14T15:08:23.169+08:00","updated_at":"2024-11-14T15:08:23.169+08:00"},{"id":34440306,"file_name":"l_3.png","project_id":818037,"asset_id":791891,"created_at":"2024-11-14T15:08:23.173+08:00","updated_at":"2024-11-14T15:08:23.173+08:00"},{"id":34440307,"file_name":"rules.png","project_id":818037,"asset_id":791860,"created_at":"2024-11-14T15:08:34.509+08:00","updated_at":"2024-11-14T15:08:34.509+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦