{"id":470325,"student_id":2589,"content":"let bg = createSprite('bg.png'); //背景\nlet hilltop = createSprite('hilltop.png'); //山頂背景\nlet b1 = createSprite('b_0.png', 'b_1.png', 'b_2.png', 'b_3.png', 'b_4.png', 'b_5.png'); //障礙物1\nlet b2 = createSprite('b_0.png', 'b_1.png', 'b_2.png', 'b_3.png', 'b_4.png', 'b_5.png'); //障礙物2\nlet b3 = createSprite('b_0.png', 'b_1.png', 'b_2.png', 'b_3.png', 'b_4.png', 'b_5.png'); //障礙物3\nlet b4 = createSprite('b_0.png', 'b_1.png', 'b_2.png', 'b_3.png', 'b_4.png', 'b_5.png'); //障礙物4\nlet n1 = createSprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png'); //分數個位數\nlet n2 = createSprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png'); //分數十位數\nlet n3 = createSprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png'); //分數百位數\nlet passerby = createSprite('y_0.png', 'y_1.png'); //路人叩叮\nlet player = createSprite('r_0.png', 'r_1.png', 'r_2.png', 'r_3.png'); //玩家\nlet monster = createSprite('m_0.png', 'm_1.png', 'm_2.png'); //雪怪\nlet enterBtn = createSprite('enter_btn.png'); // 重新開始提示按鍵\n\nlet isStart = false; // 是否開始遊戲\nlet speed = 6; // 速度\nlet score = 0; // 分數\n\nreset(); // 初始化\n\ncreateSound('bgm.mp3', true);\n\n// 重置所有角色與變數\nfunction reset () {\n hilltop.y = 450;\n bg.y = 1800;\n n1.moveTo(50, 50);\n n2.moveTo(100, 50);\n n3.moveTo(150, 50);\n b1.moveTo(1300, 0);\n b2.moveTo(1300, 300);\n b3.moveTo(1300, 600);\n b4.moveTo(1300, 900);\n monster.y = -1000;\n player.x = 600;\n passerby.y = 1200;\n enterBtn.y = 700;\n enterBtn.hidden = true;\n player.costumeId = 0;\n isStart = false;\n speed = 6;\n score = 0;\n}\n\n// 遊戲主迴圈\nfunction gameloop () {\n if (isStart \u0026\u0026 enterBtn.hidden) {\n updatePlayer(); //更新玩家\n updateMonster(); //更新雪怪\n updateGround(); //更新背景\n updateBlock(b1); //更新障礙物1\n updateBlock(b2); //更新障礙物2\n updateBlock(b3); //更新障礙物3\n updateBlock(b4); //更新障礙物4\n updatePasserby(); //更新路人叩叮\n updateScore(); //更新分數\n speedUp(); //提高遊戲速度\n }\n if (key.right || key.left) {\n isStart = true;\n }\n if (key.enter) {\n reset();\n }\n}\n\n// 更新背景圖\nfunction updateGround () {\n bg.y -= speed;\n hilltop.y -= speed;\n if (bg.y \u003c 0) {\n bg.y += 900;\n }\n}\n\n// 更新障礙物\nfunction updateBlock (block) {\n block.y -= speed;\n if (block.y \u003c -50) {\n block.y += 1200;\n block.x = 100 + Math.random() * 1000;\n block.costumeId = Math.floor(Math.random() * 6);\n block.scale = 1.3;\n }\n if (block.touched(player) \u0026\u0026 block.y \u003e player.y) {\n gameover();\n createSound('ouch.mp3');\n }\n}\n\n// 更新玩家\nfunction updatePlayer () {\n \n player.costumeId = 0; //玩家呈現向前造型圖\n\n if (key.right \u0026\u0026 player.x \u003c 1200) {\n player.x += speed * 1.5; //根據速度向右移動\n player.costumeId = 1; //呈現向右的造型圖\n }\n\n if (key.left) {\n player.x -= speed * 1.5; //根據速度向左移動\n player.costumeId = 2; //呈現向左的造型圖\n }\n}\n\n// 更新雪怪\nfunction updateMonster () {\n \n monster.y += speed / 2;\n if (monster.y \u003e 1000) {\n monster.y -= 1800;\n createSound('show.wav');\n }\n \n if (monster.x \u003e player.x) {\n monster.x -= speed / 6;\n } else {\n monster.x += speed / 6;\n }\n \n // 根據垂直 y 座標來回切換造型圖呈現走路動畫\n if (monster.y % 100 \u003c 50) {\n monster.costumeId = 0;\n } else {\n monster.costumeId = 1;\n }\n \n if (monster.touched(player) \u0026\u0026 monster.y \u003c player.y) {\n gameover()\n }\n}\n\n// 更新路人叩叮\nfunction updatePasserby () {\n \n // 如果超出上方邊界\n if (passerby.y \u003c -100) {\n passerby.y += 1200; //重置到下方\n passerby.x = Math.random() * 1000 + 100; // 隨機切換水平位置\n passerby.costumeId = 0; // 恢復造型圖\n }\n \n // 如果撞到路人叩叮而且該路人叩叮正在滑雪\n if (passerby.touched(player) \u0026\u0026 passerby.costumeId == 0) {\n passerby.costumeId = 1; //切換跌倒的圖\n score += 10; //分數加 10\n }\n \n \n if (passerby.costumeId == 0) {\n passerby.y -= speed / 2; //正在滑雪向上速度慢於背景\n } else {\n passerby.y -= speed; //跌倒了向上速度與背景相同\n }\n}\n\n// 更新分數\nfunction updateScore () {\n score += 0.01;\n n1.costumeId = Math.floor(score / 100) % 10; //更新百位數造型圖\n n2.costumeId = Math.floor(score / 10) % 10; //更新十位數造型圖\n n3.costumeId = Math.floor(score / 1) % 10; //更新個位數造型圖\n}\n\n// 遊戲結束\nfunction gameover () {\n player.costumeId = 3; // 玩家跌倒\n monster.costumeId = 2; // 雪怪嘲笑\n enterBtn.hidden = false; // 顯示重新開始提示\n}\n\n// 提高遊戲速度\nfunction speedUp () {\n if (speed \u003c 12) {\n speed += 0.001;\n }\n}\n\nforever(gameloop);","created_at":"2022-12-09T16:14:39.330+08:00","updated_at":"2023-01-29T23:41:37.917+08:00","name":"逃離雪怪(完整版)","language":"javascript","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/470325/44b2a09d4d43b9e4017c973b42835579.jpg"},"parent_id":470323,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":49,"hashid":"p93s4w2nq","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10694781,"file_name":"y_1.png","project_id":470325,"asset_id":588627,"created_at":"2022-12-09T16:14:50.936+08:00","updated_at":"2022-12-09T16:14:50.936+08:00"},{"id":10694782,"file_name":"m_1.png","project_id":470325,"asset_id":588628,"created_at":"2022-12-09T16:14:50.943+08:00","updated_at":"2022-12-09T16:14:50.943+08:00"},{"id":10694783,"file_name":"m_2.png","project_id":470325,"asset_id":588629,"created_at":"2022-12-09T16:14:50.947+08:00","updated_at":"2022-12-09T16:14:50.947+08:00"},{"id":10694784,"file_name":"r_3.png","project_id":470325,"asset_id":588630,"created_at":"2022-12-09T16:14:50.953+08:00","updated_at":"2022-12-09T16:14:50.953+08:00"},{"id":10694785,"file_name":"r_2.png","project_id":470325,"asset_id":588631,"created_at":"2022-12-09T16:14:50.958+08:00","updated_at":"2022-12-09T16:14:50.958+08:00"},{"id":10694786,"file_name":"2.png","project_id":470325,"asset_id":588632,"created_at":"2022-12-09T16:14:50.962+08:00","updated_at":"2022-12-09T16:14:50.962+08:00"},{"id":10694787,"file_name":"3.png","project_id":470325,"asset_id":588633,"created_at":"2022-12-09T16:14:50.968+08:00","updated_at":"2022-12-09T16:14:50.968+08:00"},{"id":10694788,"file_name":"4.png","project_id":470325,"asset_id":588634,"created_at":"2022-12-09T16:14:50.974+08:00","updated_at":"2022-12-09T16:14:50.974+08:00"},{"id":10694789,"file_name":"5.png","project_id":470325,"asset_id":588635,"created_at":"2022-12-09T16:14:50.980+08:00","updated_at":"2022-12-09T16:14:50.980+08:00"},{"id":10694790,"file_name":"8.png","project_id":470325,"asset_id":588636,"created_at":"2022-12-09T16:14:50.986+08:00","updated_at":"2022-12-09T16:14:50.986+08:00"},{"id":10694791,"file_name":"9.png","project_id":470325,"asset_id":588637,"created_at":"2022-12-09T16:14:50.995+08:00","updated_at":"2022-12-09T16:14:50.995+08:00"},{"id":10694792,"file_name":"6.png","project_id":470325,"asset_id":588638,"created_at":"2022-12-09T16:14:51.002+08:00","updated_at":"2022-12-09T16:14:51.002+08:00"},{"id":10694793,"file_name":"7.png","project_id":470325,"asset_id":588639,"created_at":"2022-12-09T16:14:51.008+08:00","updated_at":"2022-12-09T16:14:51.008+08:00"},{"id":10694794,"file_name":"y_0.png","project_id":470325,"asset_id":588640,"created_at":"2022-12-09T16:14:51.014+08:00","updated_at":"2022-12-09T16:14:51.014+08:00"},{"id":10694795,"file_name":"show.wav","project_id":470325,"asset_id":588641,"created_at":"2022-12-09T16:14:51.019+08:00","updated_at":"2022-12-09T16:14:51.019+08:00"},{"id":10694796,"file_name":"ouch.wav","project_id":470325,"asset_id":588642,"created_at":"2022-12-09T16:14:51.026+08:00","updated_at":"2022-12-09T16:14:51.026+08:00"},{"id":10694797,"file_name":"bgm.mp3","project_id":470325,"asset_id":588643,"created_at":"2022-12-09T16:14:51.040+08:00","updated_at":"2022-12-09T16:14:51.040+08:00"},{"id":10694798,"file_name":"bg.png","project_id":470325,"asset_id":588644,"created_at":"2022-12-09T16:14:51.047+08:00","updated_at":"2022-12-09T16:14:51.047+08:00"},{"id":10694799,"file_name":"enter_btn.png","project_id":470325,"asset_id":588645,"created_at":"2022-12-09T16:14:51.055+08:00","updated_at":"2022-12-09T16:14:51.055+08:00"},{"id":10694800,"file_name":"0.png","project_id":470325,"asset_id":588646,"created_at":"2022-12-09T16:14:51.061+08:00","updated_at":"2022-12-09T16:14:51.061+08:00"},{"id":10694801,"file_name":"1.png","project_id":470325,"asset_id":588647,"created_at":"2022-12-09T16:14:51.067+08:00","updated_at":"2022-12-09T16:14:51.067+08:00"},{"id":10694802,"file_name":"m_0.png","project_id":470325,"asset_id":588648,"created_at":"2022-12-09T16:14:51.074+08:00","updated_at":"2022-12-09T16:14:51.074+08:00"},{"id":10694803,"file_name":"r_0.png","project_id":470325,"asset_id":588649,"created_at":"2022-12-09T16:14:51.090+08:00","updated_at":"2022-12-09T16:14:51.090+08:00"},{"id":10694804,"file_name":"r_1.png","project_id":470325,"asset_id":588650,"created_at":"2022-12-09T16:14:51.095+08:00","updated_at":"2022-12-09T16:14:51.095+08:00"},{"id":10694805,"file_name":"b_2.png","project_id":470325,"asset_id":588651,"created_at":"2022-12-09T16:14:51.100+08:00","updated_at":"2022-12-09T16:14:51.100+08:00"},{"id":10694806,"file_name":"b_0.png","project_id":470325,"asset_id":588652,"created_at":"2022-12-09T16:14:51.107+08:00","updated_at":"2022-12-09T16:14:51.107+08:00"},{"id":10694807,"file_name":"b_1.png","project_id":470325,"asset_id":588653,"created_at":"2022-12-09T16:14:51.111+08:00","updated_at":"2022-12-09T16:14:51.111+08:00"},{"id":10694808,"file_name":"b_3.png","project_id":470325,"asset_id":588654,"created_at":"2022-12-09T16:14:51.118+08:00","updated_at":"2022-12-09T16:14:51.118+08:00"},{"id":10694809,"file_name":"hilltop.png","project_id":470325,"asset_id":588655,"created_at":"2022-12-09T16:14:51.154+08:00","updated_at":"2022-12-09T16:14:51.154+08:00"},{"id":10694810,"file_name":"b_5.png","project_id":470325,"asset_id":588656,"created_at":"2022-12-09T16:14:51.159+08:00","updated_at":"2022-12-09T16:14:51.159+08:00"},{"id":10694811,"file_name":"b_4.png","project_id":470325,"asset_id":588657,"created_at":"2022-12-09T16:14:51.166+08:00","updated_at":"2022-12-09T16:14:51.166+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦