{"id":431282,"student_id":10,"content":"createSprite('bg.png');\nlet player = createSprite('player.png', 'playerWithFood.png', 'playerUpset.png');\nlet instructions = createSprite('instructions.png');\nlet gameoverText = createSprite('gameover.png');\nlet bgm;\n\n['tableA.png', 'tableB.png', 'tableC.png', 'tableD.png'].forEach((img, idx) =\u003e {\n let table = createSprite(img);\n table.moveTo(450, 340 + idx * 170);\n table.layer = table.y;\n});\n\nplayer.moveTo(950, 170 * 2);\ngameoverText.layer = 1000;\ninstructions.layer = 2000;\n\nconst WAIT = 0; //等待開始\nconst PLAY = 1; //遊戲進行\nconst STOP = 2; //遊戲結束\n\nlet status = WAIT;\nlet speed = 1;\nlet score = 0;\nlet level = 0;\nlet clock = 0;\nlet playerLine = 0;\nlet beerMugs = [];\nlet customers = [];\n\nwhen('keydown', 'up', function () {\n if (playerLine \u003e 0) playerLine -= 1;\n});\n\nwhen('keydown', 'down', function () {\n if (playerLine \u003c 3) playerLine += 1;\n});\n\nwhen('keyup', 'space', createBeer);\n\nforever(gameloop);\n\nfunction gameloop() {\n instructions.hidden = status !== WAIT;\n gameoverText.hidden = status !== STOP;\n\n if (status === WAIT \u0026\u0026 key.enter) {\n startGame();\n }\n if (status === PLAY) {\n updatePlayer();\n beerMugs.forEach(updateBeer);\n customers.forEach(updateCustomer);\n updateClock();\n }\n if (status === STOP \u0026\u0026 key.q) {\n status = WAIT;\n }\n if (status === PLAY || status === STOP) {\n renderTexts();\n }\n}\n\nfunction renderTexts() {\n drawText('等級:' + level, 15, 15, 'white', 25);\n drawText('分數:' + score, 15, 45, 'white', 25);\n drawText('時間:' + Math.floor(clock / 60) + '秒', 15, 75, 'white', 25);\n}\n\nfunction startGame() {\n beerMugs.forEach(s =\u003e s.destroy());\n customers.forEach(s =\u003e s.destroy());\n beerMugs = [];\n customers = [];\n score = 0;\n level = 0;\n clock = 0;\n status = PLAY;\n bgm = createSound('bgm.wav', true);\n}\n\nfunction updateClock() {\n clock++;\n if (clock % (130 - level * 10) == 0) createCustomer();\n if (clock % 300 === 0 \u0026\u0026 level \u003c 10) level++;\n speed = 1 + level * 0.1;\n}\n\nfunction updatePlayer() {\n player.costumeId = status === STOP ? 2 : (key.space ? 1 : 0);\n player.y = playerLine * 170 + 240;\n}\n\nfunction updateBeer(s) {\n s.x -= speed * 4;\n s.scale = s.x % 200 \u003e 100 ? 0.9: 1;\n if (s.x \u003c 100 \u0026\u0026 !s.hidden) {\n gameover();\n s.costumeId = 1;\n }\n customers.forEach(customer =\u003e {\n if (s.touched(customer) \u0026\u0026 s.line === customer.line) {\n s.hidden = true;\n customer.costumeId = 1;\n score++;\n }\n });\n}\n\nfunction updateCustomer(s) {\n s.x += s.costumeId === 0 ? speed * 1.7: -speed * 5;\n if (s.x \u003c 0) s.hidden = true;\n if (s.x \u003e 780) {\n gameover();\n s.costumeId = 2;\n }\n}\n\nfunction createBeer() {\n if (status === PLAY) {\n let beer = createSprite('originalFood.png', 'brokenFood.png');\n beer.moveTo(player);\n beer.layer = 1000;\n beer.line = playerLine;\n beerMugs.push(beer);\n createSound('shoot.wav');\n }\n}\n\nfunction createCustomer() {\n let customer = createSprite('customer.png', 'customerWithFood.png', 'customerAngry.png');\n let line = Math.floor(Math.random() * 4);\n customer.x = 80;\n customer.y = line * 170 + 340 - 100; //向上位移一點\n customer.line = line;\n customer.layer = customer.y;\n customers.push(customer);\n}\n\nfunction gameover() {\n status = STOP;\n createSound('lose.wav');\n bgm.pause();\n}","created_at":"2022-09-01T18:48:05.198+08:00","updated_at":"2022-09-02T09:37:03.381+08:00","name":"達克比合作案遊戲 - Debug 副本","language":"javascript","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/431282/b230fa3bcc0fafe3f75ee57f07ce202f.jpg"},"parent_id":431269,"plugin":"Game.set({width: 1200, height: 900})\n\n\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":125,"hashid":"d5msy9kmq","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":9697156,"file_name":"bgm.mp3","project_id":431282,"asset_id":513230,"created_at":"2022-09-01T18:48:05.208+08:00","updated_at":"2022-09-01T18:48:05.208+08:00"},{"id":9697157,"file_name":"beerHit.mp3","project_id":431282,"asset_id":513231,"created_at":"2022-09-01T18:48:05.209+08:00","updated_at":"2022-09-01T18:48:05.209+08:00"},{"id":9697158,"file_name":"kitchen.png","project_id":431282,"asset_id":513248,"created_at":"2022-09-01T18:48:05.211+08:00","updated_at":"2022-09-01T18:48:05.211+08:00"},{"id":9697183,"file_name":"playerUpset.png","project_id":431282,"asset_id":560885,"created_at":"2022-09-01T18:56:34.422+08:00","updated_at":"2022-09-01T21:38:57.133+08:00"},{"id":9697184,"file_name":"player.png","project_id":431282,"asset_id":560886,"created_at":"2022-09-01T18:56:34.423+08:00","updated_at":"2022-09-01T21:39:00.241+08:00"},{"id":9697179,"file_name":"tableA.png","project_id":431282,"asset_id":560881,"created_at":"2022-09-01T18:53:30.378+08:00","updated_at":"2022-09-01T21:34:01.912+08:00"},{"id":9697180,"file_name":"tableB.png","project_id":431282,"asset_id":560882,"created_at":"2022-09-01T18:53:30.379+08:00","updated_at":"2022-09-01T21:34:05.908+08:00"},{"id":9697185,"file_name":"playerWithFood.png","project_id":431282,"asset_id":560887,"created_at":"2022-09-01T18:57:11.340+08:00","updated_at":"2022-09-01T21:39:04.469+08:00"},{"id":9697347,"file_name":"originalFood.png","project_id":431282,"asset_id":560891,"created_at":"2022-09-01T19:02:24.788+08:00","updated_at":"2022-09-01T19:02:24.788+08:00"},{"id":9697348,"file_name":"brokenFood.png","project_id":431282,"asset_id":560892,"created_at":"2022-09-01T19:02:24.791+08:00","updated_at":"2022-09-01T19:02:24.791+08:00"},{"id":9698660,"file_name":"bg.png","project_id":431282,"asset_id":560918,"created_at":"2022-09-02T06:31:59.277+08:00","updated_at":"2022-09-02T06:31:59.277+08:00"},{"id":9697344,"file_name":"customerWithFood.png","project_id":431282,"asset_id":560888,"created_at":"2022-09-01T19:01:34.831+08:00","updated_at":"2022-09-01T19:01:34.831+08:00"},{"id":9697345,"file_name":"customerAngry.png","project_id":431282,"asset_id":560889,"created_at":"2022-09-01T19:01:34.833+08:00","updated_at":"2022-09-01T19:01:34.833+08:00"},{"id":9697346,"file_name":"customer.png","project_id":431282,"asset_id":560890,"created_at":"2022-09-01T19:01:35.422+08:00","updated_at":"2022-09-01T19:01:35.422+08:00"},{"id":9697169,"file_name":"instructions.png","project_id":431282,"asset_id":516050,"created_at":"2022-09-01T18:48:05.223+08:00","updated_at":"2022-09-01T18:48:05.223+08:00"},{"id":9697170,"file_name":"shoot.wav","project_id":431282,"asset_id":275354,"created_at":"2022-09-01T18:48:05.224+08:00","updated_at":"2022-09-01T18:48:05.224+08:00"},{"id":9697171,"file_name":"bgm.wav","project_id":431282,"asset_id":275380,"created_at":"2022-09-01T18:48:05.226+08:00","updated_at":"2022-09-01T18:48:05.226+08:00"},{"id":9697172,"file_name":"lose.wav","project_id":431282,"asset_id":275369,"created_at":"2022-09-01T18:48:05.227+08:00","updated_at":"2022-09-01T18:48:05.227+08:00"},{"id":9697173,"file_name":"gameover.png","project_id":431282,"asset_id":251426,"created_at":"2022-09-01T18:48:05.228+08:00","updated_at":"2022-09-01T18:48:05.228+08:00"},{"id":9697181,"file_name":"tableC.png","project_id":431282,"asset_id":560883,"created_at":"2022-09-01T18:53:30.804+08:00","updated_at":"2022-09-01T21:34:11.249+08:00"},{"id":9697182,"file_name":"tableD.png","project_id":431282,"asset_id":560884,"created_at":"2022-09-01T18:53:30.805+08:00","updated_at":"2022-09-01T21:34:13.839+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦