{"id":868996,"student_id":10,"content":"from game import *\nfrom random import *\n\nnums = ['0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png']\nbg = create_sprite('bg.png', 'bg_success.png', 'bg_fail.png') #背景圖\nplayer = create_sprite('player.png') #扣叮\nn1 = create_sprite(nums) #千位分數\nn2 = create_sprite(nums) #百位分數\nn3 = create_sprite(nums) #十位分數\nn4 = create_sprite(nums) #個位分數\ninfo = create_sprite('rules.png') #遊戲說明\nbgm = create_sound('bgm.mp3', True) #背景音樂\n\nn1.move_to(40, 50)\nn2.move_to(90, 50)\nn3.move_to(140, 50)\nn4.move_to(190, 50)\nplayer.move_to(600, 475)\n\nitems = [] #存放墜落食材\nresults = [] #存放碗裡食材\nscore = 0 #分數\nspeed = 1 #速度\n\nfor i in range(11):\n s = create_sprite('s_' + str(i) + '.png')\n items.append(s)\n s = create_sprite('_' + str(i) + '.png')\n results.append(s)\n\n#重新開始\ndef reset():\n global score, speed\n \n # 如果拉麵製作失敗重新開始就恢復分數\n if bg.costume_id == 2: score = 0\n \n speed = 1 + score / 500 #隨著分數加快速度\n \n bg.costume_id = 0 #切換廚房背景\n player.hidden = False #顯示叩叮\n player.move_to(600, 475) #重置叩叮位置\n bgm.set_volume(1) #恢復音量\n \n for s in items:\n s.hidden = False\n s.x = random() * 1000 + 100\n s.y = random() * -3000 - 100\n s.vy = random() * 3 + 3\n \n for s in results:\n s.hidden = True\n\n#遊戲主迴圈\ndef loop():\n if info.hidden:\n update_player() #更新叩叮\n update_items() #更新食材\n update_score() #更新分數\n elif key.space:\n info.hidden = True #隱藏說明開始遊戲\n \n#更新叩叮\ndef update_player():\n if key.right: player.x += 15 * speed\n if key.left: player.x -= 15 * speed\n if key.space and bg.costume_id != 0: reset()\n \n#移動食材\ndef update_items():\n global score\n is_pass = True #所有食材是否都超出場景下方\n for s in items\n s.y += s.vy * speed\n s.direction += 1\n if not s.hidden and s.touched(player):\n s.hidden = True\n score += 1\n create_sound('splash.mp3')\n if s.y \u003c 1000: is_pass = False\n \n if is_pass: show_result() #如果所有食材超出下方就顯示結果\n \n#顯示結果\ndef show_result():\n bgm.set_volume(0.02) #降低音量\n player.hidden = True #隱藏叩叮\n for i in range(11):\n results[i].hidden = not items[i].hidden\n \n bg.costume_id = 1 #切換背景為成功拉麵碗\n\n#更新分數\ndef update_score():\n n1.costume_id = (score // 1000) % 10 #千位數\n n2.costume_id = (score // 100) % 10 #百位數\n n3.costume_id = (score // 10) % 10 #十位數\n n4.costume_id = (score // 1) % 10 #個位數\n \nforever(loop)\nreset()\n\n","created_at":"2024-10-21T11:26:56.261+08:00","updated_at":"2024-10-23T17:51:13.423+08:00","name":"拉麵配料王(預設版)","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/868996/dc87dfb2e072495a71f2b308157c6ea7.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":12,"hashid":"zpes8gn4y","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":19017184,"file_name":"0.png","project_id":868996,"asset_id":758246,"created_at":"2024-10-21T11:27:12.038+08:00","updated_at":"2024-10-21T11:27:12.038+08:00"},{"id":19017185,"file_name":"1.png","project_id":868996,"asset_id":758247,"created_at":"2024-10-21T11:27:12.040+08:00","updated_at":"2024-10-21T11:27:12.040+08:00"},{"id":19017196,"file_name":"bg.png","project_id":868996,"asset_id":786006,"created_at":"2024-10-21T11:27:15.983+08:00","updated_at":"2024-10-21T11:27:15.983+08:00"},{"id":19017197,"file_name":"bowl.png","project_id":868996,"asset_id":758259,"created_at":"2024-10-21T11:27:15.985+08:00","updated_at":"2024-10-21T11:27:15.985+08:00"},{"id":19017204,"file_name":"l_4.png","project_id":868996,"asset_id":758265,"created_at":"2024-10-21T11:27:18.272+08:00","updated_at":"2024-10-21T11:27:18.272+08:00"},{"id":19017205,"file_name":"l_5.png","project_id":868996,"asset_id":758266,"created_at":"2024-10-21T11:27:18.273+08:00","updated_at":"2024-10-21T11:27:18.273+08:00"},{"id":19017186,"file_name":"2.png","project_id":868996,"asset_id":758248,"created_at":"2024-10-21T11:27:12.399+08:00","updated_at":"2024-10-21T11:27:12.399+08:00"},{"id":19017187,"file_name":"3.png","project_id":868996,"asset_id":758249,"created_at":"2024-10-21T11:27:12.401+08:00","updated_at":"2024-10-21T11:27:12.401+08:00"},{"id":19017224,"file_name":"bg_success.png","project_id":868996,"asset_id":786011,"created_at":"2024-10-21T11:27:22.667+08:00","updated_at":"2024-10-21T11:48:49.704+08:00"},{"id":19017218,"file_name":"s_5.png","project_id":868996,"asset_id":758278,"created_at":"2024-10-21T11:27:21.335+08:00","updated_at":"2024-10-21T11:27:21.335+08:00"},{"id":19017219,"file_name":"s_6.png","project_id":868996,"asset_id":758279,"created_at":"2024-10-21T11:27:21.338+08:00","updated_at":"2024-10-21T11:27:21.338+08:00"},{"id":19017188,"file_name":"4.png","project_id":868996,"asset_id":758250,"created_at":"2024-10-21T11:27:12.783+08:00","updated_at":"2024-10-21T11:27:12.783+08:00"},{"id":19017189,"file_name":"5.png","project_id":868996,"asset_id":758251,"created_at":"2024-10-21T11:27:12.786+08:00","updated_at":"2024-10-21T11:27:12.786+08:00"},{"id":19017202,"file_name":"l_2.png","project_id":868996,"asset_id":758263,"created_at":"2024-10-21T11:27:17.871+08:00","updated_at":"2024-10-21T11:27:17.871+08:00"},{"id":19017203,"file_name":"l_3.png","project_id":868996,"asset_id":758264,"created_at":"2024-10-21T11:27:17.873+08:00","updated_at":"2024-10-21T11:27:17.873+08:00"},{"id":19017190,"file_name":"6.png","project_id":868996,"asset_id":758252,"created_at":"2024-10-21T11:27:13.141+08:00","updated_at":"2024-10-21T11:27:13.141+08:00"},{"id":19017191,"file_name":"7.png","project_id":868996,"asset_id":758253,"created_at":"2024-10-21T11:27:13.143+08:00","updated_at":"2024-10-21T11:27:13.143+08:00"},{"id":19017200,"file_name":"l_0.png","project_id":868996,"asset_id":758261,"created_at":"2024-10-21T11:27:17.440+08:00","updated_at":"2024-10-21T11:27:17.440+08:00"},{"id":19017201,"file_name":"l_1.png","project_id":868996,"asset_id":758262,"created_at":"2024-10-21T11:27:17.441+08:00","updated_at":"2024-10-21T11:27:17.441+08:00"},{"id":19017208,"file_name":"l_8.png","project_id":868996,"asset_id":758269,"created_at":"2024-10-21T11:27:19.123+08:00","updated_at":"2024-10-21T11:27:19.123+08:00"},{"id":19017209,"file_name":"l_9.png","project_id":868996,"asset_id":758270,"created_at":"2024-10-21T11:27:19.125+08:00","updated_at":"2024-10-21T11:27:19.125+08:00"},{"id":19017220,"file_name":"s_7.png","project_id":868996,"asset_id":758280,"created_at":"2024-10-21T11:27:21.710+08:00","updated_at":"2024-10-21T11:27:21.710+08:00"},{"id":19017221,"file_name":"s_8.png","project_id":868996,"asset_id":758281,"created_at":"2024-10-21T11:27:21.712+08:00","updated_at":"2024-10-21T11:27:21.712+08:00"},{"id":19017198,"file_name":"conver.png","project_id":868996,"asset_id":786007,"created_at":"2024-10-21T11:27:16.984+08:00","updated_at":"2024-10-21T11:27:16.984+08:00"},{"id":19017199,"file_name":"bg_fail.png","project_id":868996,"asset_id":786008,"created_at":"2024-10-21T11:27:16.987+08:00","updated_at":"2024-10-21T11:49:00.861+08:00"},{"id":19017206,"file_name":"l_6.png","project_id":868996,"asset_id":758267,"created_at":"2024-10-21T11:27:18.714+08:00","updated_at":"2024-10-21T11:27:18.714+08:00"},{"id":19017207,"file_name":"l_7.png","project_id":868996,"asset_id":758268,"created_at":"2024-10-21T11:27:18.716+08:00","updated_at":"2024-10-21T11:27:18.716+08:00"},{"id":19017216,"file_name":"s_3.png","project_id":868996,"asset_id":758276,"created_at":"2024-10-21T11:27:20.942+08:00","updated_at":"2024-10-21T11:27:20.942+08:00"},{"id":19017217,"file_name":"s_4.png","project_id":868996,"asset_id":758277,"created_at":"2024-10-21T11:27:20.945+08:00","updated_at":"2024-10-21T11:27:20.945+08:00"},{"id":19017222,"file_name":"s_9.png","project_id":868996,"asset_id":758282,"created_at":"2024-10-21T11:27:22.083+08:00","updated_at":"2024-10-21T11:27:22.083+08:00"},{"id":19017223,"file_name":"s_10.png","project_id":868996,"asset_id":758283,"created_at":"2024-10-21T11:27:22.085+08:00","updated_at":"2024-10-21T11:27:22.085+08:00"},{"id":19017213,"file_name":"s_0.png","project_id":868996,"asset_id":758273,"created_at":"2024-10-21T11:27:20.160+08:00","updated_at":"2024-10-21T11:27:20.160+08:00"},{"id":19017214,"file_name":"s_1.png","project_id":868996,"asset_id":758274,"created_at":"2024-10-21T11:27:20.549+08:00","updated_at":"2024-10-21T11:27:20.549+08:00"},{"id":19017215,"file_name":"s_2.png","project_id":868996,"asset_id":758275,"created_at":"2024-10-21T11:27:20.551+08:00","updated_at":"2024-10-21T11:27:20.551+08:00"},{"id":19017192,"file_name":"8.png","project_id":868996,"asset_id":758254,"created_at":"2024-10-21T11:27:13.500+08:00","updated_at":"2024-10-21T11:27:13.500+08:00"},{"id":19017193,"file_name":"9.png","project_id":868996,"asset_id":758255,"created_at":"2024-10-21T11:27:13.502+08:00","updated_at":"2024-10-21T11:27:13.502+08:00"},{"id":19017210,"file_name":"l_10.png","project_id":868996,"asset_id":758271,"created_at":"2024-10-21T11:27:19.549+08:00","updated_at":"2024-10-21T11:27:19.549+08:00"},{"id":19017211,"file_name":"player.png","project_id":868996,"asset_id":786009,"created_at":"2024-10-21T11:27:19.550+08:00","updated_at":"2024-10-21T11:27:19.550+08:00"},{"id":19022618,"file_name":"rules.png","project_id":868996,"asset_id":786099,"created_at":"2024-10-23T12:29:36.022+08:00","updated_at":"2024-10-23T12:29:36.022+08:00"},{"id":19022430,"file_name":"splash.mp3","project_id":868996,"asset_id":786033,"created_at":"2024-10-23T11:17:12.793+08:00","updated_at":"2024-10-23T11:17:12.793+08:00"},{"id":19022619,"file_name":"bgm.mp3","project_id":868996,"asset_id":786100,"created_at":"2024-10-23T12:33:46.671+08:00","updated_at":"2024-10-23T12:33:53.355+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦