{"id":863584,"student_id":1981,"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, 100)\nn2.move_to(630, 100)\nrules.layer = 1\nrules.hidden = True\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#創造叩叮\ns = create_sprite('k_0.png', 'k_1.png', 'k_2.png', 'k_3.png', 'k_4.png', 'k_5.png')\nnums.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 # if a != 2 and a != 4: a = choice(table[a])\n # if b != 2 and b != 4: b = choice(table[b])\n # if c != 2 and c != 4: c = choice(table[c])\n \n # 將數字更新至角色上\n for i in range(0):\n nums[i].costume_id = randrange(5)\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-10-15T16:12:04.044+08:00","updated_at":"2024-10-15T16:12:04.044+08:00","name":"5_間諜加加九_預設版 副本","language":"python","screenshot":{"url":null},"parent_id":830521,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"npmswqee3","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18911851,"file_name":"l_0.png","project_id":863584,"asset_id":772406,"created_at":"2024-10-15T16:12:04.050+08:00","updated_at":"2024-10-15T16:12:04.050+08:00"},{"id":18911852,"file_name":"l_1.png","project_id":863584,"asset_id":772407,"created_at":"2024-10-15T16:12:04.051+08:00","updated_at":"2024-10-15T16:12:04.051+08:00"},{"id":18911853,"file_name":"bg.png","project_id":863584,"asset_id":772408,"created_at":"2024-10-15T16:12:04.052+08:00","updated_at":"2024-10-15T16:12:04.052+08:00"},{"id":18911854,"file_name":"win.wav","project_id":863584,"asset_id":772409,"created_at":"2024-10-15T16:12:04.053+08:00","updated_at":"2024-10-15T16:12:04.053+08:00"},{"id":18911855,"file_name":"bgm.ogg","project_id":863584,"asset_id":772410,"created_at":"2024-10-15T16:12:04.055+08:00","updated_at":"2024-10-15T16:12:04.055+08:00"},{"id":18911856,"file_name":"k_4.png","project_id":863584,"asset_id":772411,"created_at":"2024-10-15T16:12:04.056+08:00","updated_at":"2024-10-15T16:12:04.056+08:00"},{"id":18911857,"file_name":"k_5.png","project_id":863584,"asset_id":772412,"created_at":"2024-10-15T16:12:04.057+08:00","updated_at":"2024-10-15T16:12:04.057+08:00"},{"id":18911858,"file_name":"rules.png","project_id":863584,"asset_id":772413,"created_at":"2024-10-15T16:12:04.058+08:00","updated_at":"2024-10-15T16:12:04.058+08:00"},{"id":18911859,"file_name":"0.png","project_id":863584,"asset_id":772414,"created_at":"2024-10-15T16:12:04.059+08:00","updated_at":"2024-10-15T16:12:04.059+08:00"},{"id":18911860,"file_name":"1.png","project_id":863584,"asset_id":772415,"created_at":"2024-10-15T16:12:04.060+08:00","updated_at":"2024-10-15T16:12:04.060+08:00"},{"id":18911861,"file_name":"2.png","project_id":863584,"asset_id":772416,"created_at":"2024-10-15T16:12:04.061+08:00","updated_at":"2024-10-15T16:12:04.061+08:00"},{"id":18911862,"file_name":"3.png","project_id":863584,"asset_id":772417,"created_at":"2024-10-15T16:12:04.062+08:00","updated_at":"2024-10-15T16:12:04.062+08:00"},{"id":18911863,"file_name":"6.png","project_id":863584,"asset_id":772418,"created_at":"2024-10-15T16:12:04.063+08:00","updated_at":"2024-10-15T16:12:04.063+08:00"},{"id":18911864,"file_name":"7.png","project_id":863584,"asset_id":772419,"created_at":"2024-10-15T16:12:04.064+08:00","updated_at":"2024-10-15T16:12:04.064+08:00"},{"id":18911865,"file_name":"l_4.png","project_id":863584,"asset_id":772420,"created_at":"2024-10-15T16:12:04.064+08:00","updated_at":"2024-10-15T16:12:04.064+08:00"},{"id":18911866,"file_name":"l_5.png","project_id":863584,"asset_id":772421,"created_at":"2024-10-15T16:12:04.065+08:00","updated_at":"2024-10-15T16:12:04.065+08:00"},{"id":18911867,"file_name":"l_10.png","project_id":863584,"asset_id":772422,"created_at":"2024-10-15T16:12:04.066+08:00","updated_at":"2024-10-15T16:12:04.066+08:00"},{"id":18911868,"file_name":"l_6.png","project_id":863584,"asset_id":772423,"created_at":"2024-10-15T16:12:04.067+08:00","updated_at":"2024-10-15T16:12:04.067+08:00"},{"id":18911869,"file_name":"l_7.png","project_id":863584,"asset_id":772424,"created_at":"2024-10-15T16:12:04.068+08:00","updated_at":"2024-10-15T16:12:04.068+08:00"},{"id":18911870,"file_name":"4.png","project_id":863584,"asset_id":772425,"created_at":"2024-10-15T16:12:04.069+08:00","updated_at":"2024-10-15T16:12:04.069+08:00"},{"id":18911871,"file_name":"5.png","project_id":863584,"asset_id":772426,"created_at":"2024-10-15T16:12:04.070+08:00","updated_at":"2024-10-15T16:12:04.070+08:00"},{"id":18911872,"file_name":"l_8.png","project_id":863584,"asset_id":772427,"created_at":"2024-10-15T16:12:04.071+08:00","updated_at":"2024-10-15T16:12:04.071+08:00"},{"id":18911873,"file_name":"l_9.png","project_id":863584,"asset_id":772428,"created_at":"2024-10-15T16:12:04.072+08:00","updated_at":"2024-10-15T16:12:04.072+08:00"},{"id":18911874,"file_name":"k_2.png","project_id":863584,"asset_id":772429,"created_at":"2024-10-15T16:12:04.072+08:00","updated_at":"2024-10-15T16:12:04.072+08:00"},{"id":18911875,"file_name":"k_3.png","project_id":863584,"asset_id":772430,"created_at":"2024-10-15T16:12:04.073+08:00","updated_at":"2024-10-15T16:12:04.073+08:00"},{"id":18911876,"file_name":"8.png","project_id":863584,"asset_id":772431,"created_at":"2024-10-15T16:12:04.074+08:00","updated_at":"2024-10-15T16:12:04.074+08:00"},{"id":18911877,"file_name":"9.png","project_id":863584,"asset_id":772432,"created_at":"2024-10-15T16:12:04.075+08:00","updated_at":"2024-10-15T16:12:04.075+08:00"},{"id":18911878,"file_name":"k_0.png","project_id":863584,"asset_id":772433,"created_at":"2024-10-15T16:12:04.076+08:00","updated_at":"2024-10-15T16:12:04.076+08:00"},{"id":18911879,"file_name":"k_1.png","project_id":863584,"asset_id":772434,"created_at":"2024-10-15T16:12:04.077+08:00","updated_at":"2024-10-15T16:12:04.077+08:00"},{"id":18911880,"file_name":"l_2.png","project_id":863584,"asset_id":772435,"created_at":"2024-10-15T16:12:04.078+08:00","updated_at":"2024-10-15T16:12:04.078+08:00"},{"id":18911881,"file_name":"l_3.png","project_id":863584,"asset_id":772436,"created_at":"2024-10-15T16:12:04.079+08:00","updated_at":"2024-10-15T16:12:04.079+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦