{"id":847540,"student_id":3760,"content":"from game import *\nfrom random import *\n\nset_backdrop('bg.png')\nnumbers = ['n_' + str(i) + '.png' for i in range(10)]\np1 = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_9.png') #放底層麵包的叩叮\np2 = create_sprite('p_0.png', 'p_3.png', 'p_4.png', 'p_7.png', 'p_8.png', 'p_9.png') #放肉片的叩叮\np3 = create_sprite('p_0.png', 'p_5.png', 'p_6.png', 'p_10.png') #放上層麵包的叩叮\np4 = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_12.png') #負責檢查的叩叮\nh1 = create_sprite('h_0.png', 'h_1.png', 'h_2.png', 'h_3.png', 'h_4.png') #漢堡\nh2 = create_sprite('h_0.png', 'h_1.png', 'h_2.png', 'h_3.png', 'h_4.png') #漢堡\nh3 = create_sprite('h_0.png', 'h_1.png', 'h_2.png', 'h_3.png', 'h_4.png') #漢堡\nh4 = create_sprite('h_0.png', 'h_1.png', 'h_2.png', 'h_3.png', 'h_4.png') #漢堡\nstatus = create_sprite('s1.png', 's2.png', 's3.png', 's4.png', 's5.png') #狀態燈號\nn1 = create_sprite(numbers) #百位數分數\nn2 = create_sprite(numbers) #十位數分數\nn3 = create_sprite(numbers) #個位數分數\nunit = create_sprite('text.png') #出貨文字\nrules = create_sprite('rules.png') #遊戲規則說明\np1.move_to(150, 450)\np2.move_to(450, 450)\np3.move_to(750, 450)\np4.move_to(1050, 450)\nh1.move_to(150, 650)\nh2.move_to(450, 650)\nh3.move_to(750, 650)\nh4.move_to(1050, 650)\nn1.move_to(50, 75)\nn2.move_to(110, 75)\nn3.move_to(170, 75)\nunit.move_to(300, 75)\nstatus.move_to(1000, 50)\n\n# bgm = create_sound('bgm.ogg', True) #背景音樂\nh1.costume_id = 1\n\nclock = 0 #遊戲迴圈執行次數\nactive = False #是否按下方向鍵下\nscore = 0 #玩家分數\n\n# 遊戲迴圈\ndef loop():\n global clock, active, score\n clock += 1\n if rules.hidden and clock % (15 - score // 5) == 0:\n if status.costume_id == 0: move_right() #向右前進\n elif status.costume_id == 1: all_put() #放置食材\n elif status.costume_id == 2: move_left() #向左退回\n elif status.costume_id == 3: p2_put() #補放食材\n \n if key.enter: rules.hidden = True #按下 enter 就隱藏遊戲說明\n if key.left and status.costume_id == 0: status.costume_id = 2 #按下方向鍵左就退回\n if key.down and status.costume_id == 0: active = True #按方向鍵下就放食材\n if status.costume_id == 0 and h1.x == 150: active = False #切換回移動時,就清空 active 變數\n if status.costume_id == 1 and h4.costume_id != 3 and h4.costume_id != 0: gameover() #如果漢堡不是空的或完整遊戲就結束\n if status.costume_id == 3 and h2.costume_id != 1: gameover() #如果退回有肉的漢堡遊戲就結束\n update_score() #更新分數角色\n\n# 向右前進\ndef move_right():\n global score\n if h1.x \u003c 450: # 如果漢堡還沒移動到第二隻叩叮面前,就向前移動\n h1.x += 60\n h2.x += 60\n h3.x += 60\n h4.x += 60\n else: # 否則就後退重置並切換造型圖\n h1.x -= 300\n h2.x -= 300\n h3.x -= 300\n h4.x -= 300\n if h4.costume_id == 3: score += 1\n h4.costume_id = h3.costume_id\n h3.costume_id = h2.costume_id\n h2.costume_id = h1.costume_id\n h1.costume_id = 0\n status.costume_id = 1\n\n# 向左退回\ndef move_left():\n h1.x -= 60\n h2.x -= 60\n h3.x -= 60\n h4.x -= 60\n if h1.x \u003c= 150: #如果漢堡後退到叩叮面前,就將狀態切換成補放\n status.costume_id = 3\n\n# 放置食材\ndef all_put():\n if h1.costume_id == 0: p1_put()\n if h2.costume_id == 1: p2_put()\n if active: p3_put()\n # create_sound('put.ogg') #放置音效\n\n# 第一隻叩叮放食材\ndef p1_put():\n if p1.costume_id == 0:\n p1.costume_id = 1\n elif p1.costume_id == 1:\n p1.costume_id = 2\n else:\n p1.costume_id = 0\n h1.costume_id += 1\n\n# 第二隻叩叮放食材\ndef p2_put():\n if p2.costume_id == 0:\n if random() \u003c 0.8: p2.costume_id = 1\n else: p2.costume_id = 3\n elif p2.costume_id == 1:\n p2.costume_id = 2\n elif p2.costume_id == 3:\n p2.costume_id = 4\n else:\n if p2.costume_id == 2: h2.costume_id += 1\n p2.costume_id = 0\n status.costume_id = 0\n \n# 第三隻叩叮放食材 \ndef p3_put():\n global active\n if p3.costume_id == 0:\n p3.costume_id = 1\n elif p3.costume_id == 1:\n p3.costume_id = 2\n else:\n p3.costume_id = 0\n if h3.costume_id == 2: h3.costume_id = 3\n if h3.costume_id == 1: h3.costume_id = 4\n\n# 遊戲結束\ndef gameover():\n p1.costume_id = 3\n p2.costume_id = 5\n p3.costume_id = 3\n p4.costume_id = 3\n status.costume_id = 4\n # bgm.pause()\n\n# 更新分數角色 \ndef update_score():\n n1.costume_id = (score // 100) % 10\n n2.costume_id = (score // 10) % 10\n n3.costume_id = (score // 1) % 10\n if status.costume_id == 4 and clock % 30 == 0:\n n1.hidden = not n1.hidden\n n2.hidden = not n2.hidden\n n3.hidden = not n3.hidden\n unit.hidden = not unit.hidden\n \nforever(loop)\n ","created_at":"2024-09-25T15:01:46.785+08:00","updated_at":"2024-09-25T18:34:29.340+08:00","name":"4_漢堡工廠_預設版 副本","language":"python","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/847540/88e598b349725c39815a9727816469c5.jpg"},"parent_id":829990,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":21,"hashid":"4y3s3w6ng","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18604354,"file_name":"bg.png","project_id":847540,"asset_id":771684,"created_at":"2024-09-25T15:01:46.791+08:00","updated_at":"2024-09-25T15:01:46.791+08:00"},{"id":18604355,"file_name":"h_0.png","project_id":847540,"asset_id":771685,"created_at":"2024-09-25T15:01:46.792+08:00","updated_at":"2024-09-25T15:01:46.792+08:00"},{"id":18604356,"file_name":"p_0.png","project_id":847540,"asset_id":771686,"created_at":"2024-09-25T15:01:46.793+08:00","updated_at":"2024-09-25T15:01:46.793+08:00"},{"id":18604357,"file_name":"p_1.png","project_id":847540,"asset_id":771687,"created_at":"2024-09-25T15:01:46.794+08:00","updated_at":"2024-09-25T15:01:46.794+08:00"},{"id":18604358,"file_name":"p_8.png","project_id":847540,"asset_id":771688,"created_at":"2024-09-25T15:01:46.795+08:00","updated_at":"2024-09-25T15:01:46.795+08:00"},{"id":18604359,"file_name":"p_9.png","project_id":847540,"asset_id":771689,"created_at":"2024-09-25T15:01:46.796+08:00","updated_at":"2024-09-25T15:01:46.796+08:00"},{"id":18604360,"file_name":"h_3.png","project_id":847540,"asset_id":771690,"created_at":"2024-09-25T15:01:46.797+08:00","updated_at":"2024-09-25T15:01:46.797+08:00"},{"id":18604361,"file_name":"h_4.png","project_id":847540,"asset_id":771691,"created_at":"2024-09-25T15:01:46.798+08:00","updated_at":"2024-09-25T15:01:46.798+08:00"},{"id":18604362,"file_name":"put.ogg","project_id":847540,"asset_id":771692,"created_at":"2024-09-25T15:01:46.799+08:00","updated_at":"2024-09-25T15:01:46.799+08:00"},{"id":18604363,"file_name":"s3.png","project_id":847540,"asset_id":771693,"created_at":"2024-09-25T15:01:46.800+08:00","updated_at":"2024-09-25T15:01:46.800+08:00"},{"id":18604364,"file_name":"s4.png","project_id":847540,"asset_id":771694,"created_at":"2024-09-25T15:01:46.801+08:00","updated_at":"2024-09-25T15:01:46.801+08:00"},{"id":18604365,"file_name":"n_2.png","project_id":847540,"asset_id":771695,"created_at":"2024-09-25T15:01:46.802+08:00","updated_at":"2024-09-25T15:01:46.802+08:00"},{"id":18604366,"file_name":"n_3.png","project_id":847540,"asset_id":771696,"created_at":"2024-09-25T15:01:46.803+08:00","updated_at":"2024-09-25T15:01:46.803+08:00"},{"id":18604367,"file_name":"n_8.png","project_id":847540,"asset_id":771697,"created_at":"2024-09-25T15:01:46.804+08:00","updated_at":"2024-09-25T15:01:46.804+08:00"},{"id":18604368,"file_name":"n_9.png","project_id":847540,"asset_id":771698,"created_at":"2024-09-25T15:01:46.805+08:00","updated_at":"2024-09-25T15:01:46.805+08:00"},{"id":18604369,"file_name":"p_4.png","project_id":847540,"asset_id":771699,"created_at":"2024-09-25T15:01:46.805+08:00","updated_at":"2024-09-25T15:01:46.805+08:00"},{"id":18604370,"file_name":"p_5.png","project_id":847540,"asset_id":771700,"created_at":"2024-09-25T15:01:46.806+08:00","updated_at":"2024-09-25T15:01:46.806+08:00"},{"id":18604371,"file_name":"h_1.png","project_id":847540,"asset_id":771701,"created_at":"2024-09-25T15:01:46.807+08:00","updated_at":"2024-09-25T15:01:46.807+08:00"},{"id":18604372,"file_name":"h_2.png","project_id":847540,"asset_id":771702,"created_at":"2024-09-25T15:01:46.808+08:00","updated_at":"2024-09-25T15:01:46.808+08:00"},{"id":18604373,"file_name":"p_6.png","project_id":847540,"asset_id":771703,"created_at":"2024-09-25T15:01:46.809+08:00","updated_at":"2024-09-25T15:01:46.809+08:00"},{"id":18604374,"file_name":"p_7.png","project_id":847540,"asset_id":771704,"created_at":"2024-09-25T15:01:46.810+08:00","updated_at":"2024-09-25T15:01:46.810+08:00"},{"id":18604375,"file_name":"p_10.png","project_id":847540,"asset_id":771705,"created_at":"2024-09-25T15:01:46.811+08:00","updated_at":"2024-09-25T15:01:46.811+08:00"},{"id":18604376,"file_name":"p_11.png","project_id":847540,"asset_id":771706,"created_at":"2024-09-25T15:01:46.812+08:00","updated_at":"2024-09-25T15:01:46.812+08:00"},{"id":18604377,"file_name":"s1.png","project_id":847540,"asset_id":771707,"created_at":"2024-09-25T15:01:46.813+08:00","updated_at":"2024-09-25T15:01:46.813+08:00"},{"id":18604378,"file_name":"s2.png","project_id":847540,"asset_id":771708,"created_at":"2024-09-25T15:01:46.814+08:00","updated_at":"2024-09-25T15:01:46.814+08:00"},{"id":18604379,"file_name":"s5.png","project_id":847540,"asset_id":771709,"created_at":"2024-09-25T15:01:46.815+08:00","updated_at":"2024-09-25T15:01:46.815+08:00"},{"id":18604380,"file_name":"text.png","project_id":847540,"asset_id":771710,"created_at":"2024-09-25T15:01:46.816+08:00","updated_at":"2024-09-25T15:01:46.816+08:00"},{"id":18604381,"file_name":"n_0.png","project_id":847540,"asset_id":771711,"created_at":"2024-09-25T15:01:46.817+08:00","updated_at":"2024-09-25T15:01:46.817+08:00"},{"id":18604382,"file_name":"n_1.png","project_id":847540,"asset_id":771712,"created_at":"2024-09-25T15:01:46.818+08:00","updated_at":"2024-09-25T15:01:46.818+08:00"},{"id":18604383,"file_name":"p_12.png","project_id":847540,"asset_id":771713,"created_at":"2024-09-25T15:01:46.819+08:00","updated_at":"2024-09-25T15:01:46.819+08:00"},{"id":18604384,"file_name":"rules.png","project_id":847540,"asset_id":771714,"created_at":"2024-09-25T15:01:46.820+08:00","updated_at":"2024-09-25T15:01:46.820+08:00"},{"id":18604385,"file_name":"n_4.png","project_id":847540,"asset_id":771715,"created_at":"2024-09-25T15:01:46.820+08:00","updated_at":"2024-09-25T15:01:46.820+08:00"},{"id":18604386,"file_name":"n_5.png","project_id":847540,"asset_id":771716,"created_at":"2024-09-25T15:01:46.821+08:00","updated_at":"2024-09-25T15:01:46.821+08:00"},{"id":18604387,"file_name":"p_2.png","project_id":847540,"asset_id":771717,"created_at":"2024-09-25T15:01:46.822+08:00","updated_at":"2024-09-25T15:01:46.822+08:00"},{"id":18604388,"file_name":"p_3.png","project_id":847540,"asset_id":771718,"created_at":"2024-09-25T15:01:46.823+08:00","updated_at":"2024-09-25T15:01:46.823+08:00"},{"id":18604389,"file_name":"n_6.png","project_id":847540,"asset_id":771719,"created_at":"2024-09-25T15:01:46.824+08:00","updated_at":"2024-09-25T15:01:46.824+08:00"},{"id":18604390,"file_name":"n_7.png","project_id":847540,"asset_id":771720,"created_at":"2024-09-25T15:01:46.825+08:00","updated_at":"2024-09-25T15:01:46.825+08:00"},{"id":18604391,"file_name":"bgm.ogg","project_id":847540,"asset_id":771721,"created_at":"2024-09-25T15:01:46.825+08:00","updated_at":"2024-09-25T15:01:46.825+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦