{"id":472962,"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.wav');\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 \u0026\u0026 player.x \u003e 0) {\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-12T15:19:18.172+08:00","updated_at":"2023-12-01T16:26:30.109+08:00","name":"逃離雪怪 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/472962/5c2b2e2580afa03f30a2cf245f45b0e5.jpg"},"parent_id":470325,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":55,"hashid":"ej9s9q2pd","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10761304,"file_name":"y_1.png","project_id":472962,"asset_id":588627,"created_at":"2022-12-12T15:19:18.178+08:00","updated_at":"2022-12-12T15:19:18.178+08:00"},{"id":10761305,"file_name":"m_1.png","project_id":472962,"asset_id":588628,"created_at":"2022-12-12T15:19:18.181+08:00","updated_at":"2022-12-12T15:19:18.181+08:00"},{"id":10761306,"file_name":"m_2.png","project_id":472962,"asset_id":588629,"created_at":"2022-12-12T15:19:18.182+08:00","updated_at":"2022-12-12T15:19:18.182+08:00"},{"id":10761307,"file_name":"r_3.png","project_id":472962,"asset_id":588630,"created_at":"2022-12-12T15:19:18.183+08:00","updated_at":"2022-12-12T15:19:18.183+08:00"},{"id":10761308,"file_name":"r_2.png","project_id":472962,"asset_id":588631,"created_at":"2022-12-12T15:19:18.184+08:00","updated_at":"2022-12-12T15:19:18.184+08:00"},{"id":10761309,"file_name":"2.png","project_id":472962,"asset_id":588632,"created_at":"2022-12-12T15:19:18.186+08:00","updated_at":"2022-12-12T15:19:18.186+08:00"},{"id":10761310,"file_name":"3.png","project_id":472962,"asset_id":588633,"created_at":"2022-12-12T15:19:18.187+08:00","updated_at":"2022-12-12T15:19:18.187+08:00"},{"id":10761311,"file_name":"4.png","project_id":472962,"asset_id":588634,"created_at":"2022-12-12T15:19:18.188+08:00","updated_at":"2022-12-12T15:19:18.188+08:00"},{"id":10761312,"file_name":"5.png","project_id":472962,"asset_id":588635,"created_at":"2022-12-12T15:19:18.189+08:00","updated_at":"2022-12-12T15:19:18.189+08:00"},{"id":10761313,"file_name":"8.png","project_id":472962,"asset_id":588636,"created_at":"2022-12-12T15:19:18.190+08:00","updated_at":"2022-12-12T15:19:18.190+08:00"},{"id":10761314,"file_name":"9.png","project_id":472962,"asset_id":588637,"created_at":"2022-12-12T15:19:18.191+08:00","updated_at":"2022-12-12T15:19:18.191+08:00"},{"id":10761315,"file_name":"6.png","project_id":472962,"asset_id":588638,"created_at":"2022-12-12T15:19:18.192+08:00","updated_at":"2022-12-12T15:19:18.192+08:00"},{"id":10761316,"file_name":"7.png","project_id":472962,"asset_id":588639,"created_at":"2022-12-12T15:19:18.193+08:00","updated_at":"2022-12-12T15:19:18.193+08:00"},{"id":10761317,"file_name":"y_0.png","project_id":472962,"asset_id":588640,"created_at":"2022-12-12T15:19:18.194+08:00","updated_at":"2022-12-12T15:19:18.194+08:00"},{"id":10761318,"file_name":"show.wav","project_id":472962,"asset_id":588641,"created_at":"2022-12-12T15:19:18.195+08:00","updated_at":"2022-12-12T15:19:18.195+08:00"},{"id":10761319,"file_name":"ouch.wav","project_id":472962,"asset_id":588642,"created_at":"2022-12-12T15:19:18.197+08:00","updated_at":"2022-12-12T15:19:18.197+08:00"},{"id":10761320,"file_name":"bgm.mp3","project_id":472962,"asset_id":588643,"created_at":"2022-12-12T15:19:18.198+08:00","updated_at":"2022-12-12T15:19:18.198+08:00"},{"id":10761321,"file_name":"bg.png","project_id":472962,"asset_id":588644,"created_at":"2022-12-12T15:19:18.199+08:00","updated_at":"2022-12-12T15:19:18.199+08:00"},{"id":10761322,"file_name":"enter_btn.png","project_id":472962,"asset_id":588645,"created_at":"2022-12-12T15:19:18.200+08:00","updated_at":"2022-12-12T15:19:18.200+08:00"},{"id":10761323,"file_name":"0.png","project_id":472962,"asset_id":588646,"created_at":"2022-12-12T15:19:18.202+08:00","updated_at":"2022-12-12T15:19:18.202+08:00"},{"id":10761324,"file_name":"1.png","project_id":472962,"asset_id":588647,"created_at":"2022-12-12T15:19:18.203+08:00","updated_at":"2022-12-12T15:19:18.203+08:00"},{"id":10761325,"file_name":"m_0.png","project_id":472962,"asset_id":588648,"created_at":"2022-12-12T15:19:18.204+08:00","updated_at":"2022-12-12T15:19:18.204+08:00"},{"id":10761326,"file_name":"r_0.png","project_id":472962,"asset_id":588649,"created_at":"2022-12-12T15:19:18.205+08:00","updated_at":"2022-12-12T15:19:18.205+08:00"},{"id":10761327,"file_name":"r_1.png","project_id":472962,"asset_id":588650,"created_at":"2022-12-12T15:19:18.210+08:00","updated_at":"2022-12-12T15:19:18.210+08:00"},{"id":10761328,"file_name":"b_2.png","project_id":472962,"asset_id":588651,"created_at":"2022-12-12T15:19:18.211+08:00","updated_at":"2022-12-12T15:19:18.211+08:00"},{"id":10761329,"file_name":"b_0.png","project_id":472962,"asset_id":588652,"created_at":"2022-12-12T15:19:18.212+08:00","updated_at":"2022-12-12T15:19:18.212+08:00"},{"id":10761330,"file_name":"b_1.png","project_id":472962,"asset_id":588653,"created_at":"2022-12-12T15:19:18.214+08:00","updated_at":"2022-12-12T15:19:18.214+08:00"},{"id":10761331,"file_name":"b_3.png","project_id":472962,"asset_id":588654,"created_at":"2022-12-12T15:19:18.215+08:00","updated_at":"2022-12-12T15:19:18.215+08:00"},{"id":10761332,"file_name":"hilltop.png","project_id":472962,"asset_id":588655,"created_at":"2022-12-12T15:19:18.216+08:00","updated_at":"2022-12-12T15:19:18.216+08:00"},{"id":10761333,"file_name":"b_5.png","project_id":472962,"asset_id":588656,"created_at":"2022-12-12T15:19:18.218+08:00","updated_at":"2022-12-12T15:19:18.218+08:00"},{"id":10761334,"file_name":"b_4.png","project_id":472962,"asset_id":588657,"created_at":"2022-12-12T15:19:18.219+08:00","updated_at":"2022-12-12T15:19:18.219+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦