{"id":354237,"student_id":10,"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\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 }\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 // 根據垂直 y 座標來回切換造型圖呈現走路動畫\n if (monster.y % 100 \u003c 50) {\n monster.costumeId = 0;\n } else {\n monster.costumeId = 1;\n }\n \n monster.y += speed / 2;\n if (monster.y \u003e 1000) {\n monster.y -= 1800;\n }\n \n if (monster.x \u003e player.x) {\n monster.x -= speed / 6;\n } else {\n monster.x += speed / 6;\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// 更新分數sp\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-03-09T08:50:11.469+08:00","updated_at":"2022-11-23T09:20:38.603+08:00","name":"逃離雪怪(完整版)","language":"javascript","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/354237/a2fcd2e717a422e5b6e7fe7ee425bfe4.jpg"},"parent_id":354049,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":157,"hashid":"zpesjn33g","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10462328,"file_name":"y_1.png","project_id":354237,"asset_id":582901,"created_at":"2022-11-16T17:45:04.790+08:00","updated_at":"2022-11-16T17:45:04.790+08:00"},{"id":10462329,"file_name":"m_1.png","project_id":354237,"asset_id":582902,"created_at":"2022-11-16T17:45:04.798+08:00","updated_at":"2022-11-16T17:45:04.798+08:00"},{"id":10462330,"file_name":"m_2.png","project_id":354237,"asset_id":582903,"created_at":"2022-11-16T17:45:04.805+08:00","updated_at":"2022-11-16T17:45:04.805+08:00"},{"id":10462331,"file_name":"r_3.png","project_id":354237,"asset_id":582904,"created_at":"2022-11-16T17:45:04.813+08:00","updated_at":"2022-11-16T17:45:04.813+08:00"},{"id":10462332,"file_name":"r_2.png","project_id":354237,"asset_id":582905,"created_at":"2022-11-16T17:45:04.821+08:00","updated_at":"2022-11-16T17:45:04.821+08:00"},{"id":10462333,"file_name":"2.png","project_id":354237,"asset_id":582906,"created_at":"2022-11-16T17:45:04.830+08:00","updated_at":"2022-11-16T17:45:04.830+08:00"},{"id":10462334,"file_name":"3.png","project_id":354237,"asset_id":582907,"created_at":"2022-11-16T17:45:04.837+08:00","updated_at":"2022-11-16T17:45:04.837+08:00"},{"id":10462335,"file_name":"4.png","project_id":354237,"asset_id":582908,"created_at":"2022-11-16T17:45:04.844+08:00","updated_at":"2022-11-16T17:45:04.844+08:00"},{"id":10462336,"file_name":"5.png","project_id":354237,"asset_id":582909,"created_at":"2022-11-16T17:45:04.850+08:00","updated_at":"2022-11-16T17:45:04.850+08:00"},{"id":10462337,"file_name":"8.png","project_id":354237,"asset_id":582910,"created_at":"2022-11-16T17:45:04.857+08:00","updated_at":"2022-11-16T17:45:04.857+08:00"},{"id":10462338,"file_name":"9.png","project_id":354237,"asset_id":582911,"created_at":"2022-11-16T17:45:04.864+08:00","updated_at":"2022-11-16T17:45:04.864+08:00"},{"id":10462339,"file_name":"6.png","project_id":354237,"asset_id":582912,"created_at":"2022-11-16T17:45:04.871+08:00","updated_at":"2022-11-16T17:45:04.871+08:00"},{"id":10462340,"file_name":"7.png","project_id":354237,"asset_id":582913,"created_at":"2022-11-16T17:45:04.878+08:00","updated_at":"2022-11-16T17:45:04.878+08:00"},{"id":10462341,"file_name":"y_0.png","project_id":354237,"asset_id":582914,"created_at":"2022-11-16T17:45:04.885+08:00","updated_at":"2022-11-16T17:45:04.885+08:00"},{"id":10462342,"file_name":"show.wav","project_id":354237,"asset_id":582915,"created_at":"2022-11-16T17:45:04.892+08:00","updated_at":"2022-11-16T17:45:04.892+08:00"},{"id":10462343,"file_name":"ouch.wav","project_id":354237,"asset_id":582916,"created_at":"2022-11-16T17:45:04.898+08:00","updated_at":"2022-11-16T17:45:04.898+08:00"},{"id":10462344,"file_name":"bgm.mp3","project_id":354237,"asset_id":582917,"created_at":"2022-11-16T17:45:04.913+08:00","updated_at":"2022-11-16T17:45:04.913+08:00"},{"id":10462345,"file_name":"bg.png","project_id":354237,"asset_id":582918,"created_at":"2022-11-16T17:45:04.921+08:00","updated_at":"2022-11-16T17:45:04.921+08:00"},{"id":10462346,"file_name":"enter_btn.png","project_id":354237,"asset_id":582919,"created_at":"2022-11-16T17:45:04.928+08:00","updated_at":"2022-11-16T17:45:04.928+08:00"},{"id":10462347,"file_name":"0.png","project_id":354237,"asset_id":582920,"created_at":"2022-11-16T17:45:04.959+08:00","updated_at":"2022-11-16T17:45:04.959+08:00"},{"id":10462348,"file_name":"1.png","project_id":354237,"asset_id":582921,"created_at":"2022-11-16T17:45:04.966+08:00","updated_at":"2022-11-16T17:45:04.966+08:00"},{"id":10462349,"file_name":"m_0.png","project_id":354237,"asset_id":582922,"created_at":"2022-11-16T17:45:04.974+08:00","updated_at":"2022-11-16T17:45:04.974+08:00"},{"id":10462350,"file_name":"r_0.png","project_id":354237,"asset_id":582923,"created_at":"2022-11-16T17:45:04.981+08:00","updated_at":"2022-11-16T17:45:04.981+08:00"},{"id":10462351,"file_name":"r_1.png","project_id":354237,"asset_id":582924,"created_at":"2022-11-16T17:45:04.989+08:00","updated_at":"2022-11-16T17:45:04.989+08:00"},{"id":10462352,"file_name":"b_2.png","project_id":354237,"asset_id":582925,"created_at":"2022-11-16T17:45:04.997+08:00","updated_at":"2022-11-16T17:45:04.997+08:00"},{"id":10462353,"file_name":"b_0.png","project_id":354237,"asset_id":582926,"created_at":"2022-11-16T17:45:05.004+08:00","updated_at":"2022-11-16T17:45:05.004+08:00"},{"id":10462354,"file_name":"b_1.png","project_id":354237,"asset_id":582927,"created_at":"2022-11-16T17:45:05.010+08:00","updated_at":"2022-11-16T17:45:05.010+08:00"},{"id":10462355,"file_name":"b_3.png","project_id":354237,"asset_id":582928,"created_at":"2022-11-16T17:45:05.017+08:00","updated_at":"2022-11-16T17:45:05.017+08:00"},{"id":10462356,"file_name":"hilltop.png","project_id":354237,"asset_id":582929,"created_at":"2022-11-16T17:45:05.026+08:00","updated_at":"2022-11-16T17:45:05.026+08:00"},{"id":10462357,"file_name":"b_5.png","project_id":354237,"asset_id":582930,"created_at":"2022-11-16T17:45:05.033+08:00","updated_at":"2022-11-16T17:45:05.033+08:00"},{"id":10462358,"file_name":"b_4.png","project_id":354237,"asset_id":582931,"created_at":"2022-11-16T17:45:05.040+08:00","updated_at":"2022-11-16T17:45:05.040+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦