{"id":507124,"student_id":2589,"content":"let bg = createSprite('bg.png'); //背景圖\nlet player = createSprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png'); //叩叮玩家\nlet monster = createSprite('monster_0.png', 'monster_1.png', 'monster_2.png'); //怪物\nlet gameover = createSprite('gameover.png'); //遊戲結束\nlet nums = ['0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png'];\nlet num1 = createSprite(nums); //千位\nlet num2 = createSprite(nums); //百位\nlet num3 = createSprite(nums); //十位\nlet num4 = createSprite(nums); //個位\n\nlet speed = 10; //向上跳的速度\nlet score = 0; //完成的階梯數\nlet timer = 0; //道具作用剩餘時間\nlet blocks = []; // 存放階梯的陣列\n\n// 設定角色的圖層\nplayer.layer = 1;\ngameover.layer = 2;\nnum1.layer = num2.layer = num3.layer = num4.layer = 3;\nplayer.rotationStyle = 'flipped';\ngameover.hidden = true;\n\nnum1.moveTo(50, 50);\nnum2.moveTo(120, 50);\nnum3.moveTo(190, 50);\nnum4.moveTo(260, 50);\n\n// 使用迴圈創造 16 個階梯角色\nfor (let i = 0; i \u003c 16; i++) {\n let b = createSprite('b_0.png', 'b_1.png', 'b_22.png', 'b_3.png', 'b_4.png', 'b_5.png');\n blocks[i] = b; // 將階梯角色存入陣列\n}\n\nrestart();\nforever(gameloop);\ngameover.on('click', restart);\n\n// 重新開始遊戲\nfunction restart () {\n speed = 0; //重置速度\n score = 0; //重置分數\n timer = 0; //重置計時器\n player.moveTo(600, 450); //重置玩家位置\n player.costumeId = 0; //重置玩家造型\n monster.y = -3000; //重置怪物位置\n \n for (let i = 0; i \u003c 16; i++) { //重置階梯\n blocks[i].x = Math.random() * 1200; //隨機水平位置\n blocks[i].y = i * 60; //垂直相隔 60\n }\n}\n\n// //遊戲迴圈\nfunction gameloop () {\n updatePlayer(); //更新玩家\n blocks.forEach(updateBlock); //更新階梯\n scroll(); // 捲動所有角色\n updateMonster(); //更新怪物\n updateScore(); //更新遊戲分數\n if (bg.y \u003e 900) bg.y -= 1800;\n}\n\n// 更新玩家位置\nfunction updatePlayer() {\n if (key.right) {\n player.x += 10; //向右移動 10\n player.direction = 90; //圖片水平翻轉向右\n }\n if (key.left) {\n player.x -= 10; //左右移動 10\n player.direction = 270; //圖片水平翻轉向左\n }\n if (player.x \u003c 0) player.x += 1200;\n if (player.x \u003e 1200) player.x -= 1200;\n\n speed -= 0.5;\n player.y -= speed;\n \n // 如果玩家不是昏倒造型\n if (player.costumeId != 3) {\n timer -= 1; //減少效果時間\n if (timer \u003c 0) player.costumeId = 0; //解除效果\n if (player.costumeId == 1) speed = 30; //氣球飛行\n if (player.costumeId == 2) speed = 60; //老鷹衝刺\n }\n \n gameover.hidden = player.y \u003c 1000;\n}\n\n// 相對移動\nfunction scroll () {\n let offset = 450 - player.y;\n if (offset \u003e 0) {\n bg.y += offset;\n player.y += offset;\n monster.y += offset;\n for (let i = 0; i \u003c 16; i++) {\n blocks[i].y += offset;\n }\n }\n}\n\n// 更新階梯位置\nfunction updateBlock (block) {\n if (block.y \u003e 930) {\n block.y -= 60 * 16 + score * 2; //根據分數拉開階梯距離\n block.x = Math.random() * 1200; //隨機水平位置\n let rand = Math.random() * 100;\n if (rand \u003c 70) block.costumeId = 0; //70% 機率一般石階\n else if (rand \u003c 85) block.costumeId = 1; //15% 機率草叢石階\n else if (rand \u003c 90) block.costumeId = 2; //5% 飛鶴\n else if (rand \u003c 95) block.costumeId = 3; //5% 雲朵\n else if (rand \u003c 99) block.costumeId = 4; //4% 氣球\n else block.costumeId = 5; //1% 老鷹\n score += 1;\n }\n \n if (block.costumeId == 2) block.x += 5; //如果是白鶴就向右移動\n if (block.x \u003e 1300) block.x -= 1400; //如果移動超出邊界就重置到左側\n \n if (block.touched(player) \u0026\u0026 player.y \u003c block.y \u0026\u0026 speed \u003c 0 \u0026\u0026 player.costumeId != 3) {\n speed = 20; // 跳起速度設為 20\n block.scale = 1.3;\n let id = block.costumeId //用變數簡短造型編號\n if (id == 1) speed = 30; //草叢階梯效果\n if (id == 3 || id == 4 || id == 5) block.hidden = true; //雲朵階梯效果\n if (id == 4) {\n player.costumeId = 1;\n timer = 60;\n }\n if (id == 5) {\n player.costumeId = 2;\n timer = 120;\n }\n }\n if (block.scale \u003e 1) block.scale -= 0.03;\n}\n\n// 更新怪物\nfunction updateMonster () {\n // 如果怪物超出下方邊界就重置到上方\n if (monster.y \u003e 1000) {\n monster.y -= 5000;\n monster.x = Math.random() * 1200;\n monster.costumeId = Math.floor(Math.random() * 3);\n }\n // 如果玩家碰到怪物而且速度向下\n if (monster.touched(player) \u0026\u0026 speed \u003c 0) {\n player.costumeId = 3; //切換昏倒造型\n }\n}\n\n// 更新分數\nfunction updateScore () {\n num1.costumeId = Math.floor(score / 1000) % 10; //更新千位造型\n num2.costumeId = Math.floor(score / 100) % 10; //更新百位造型\n num3.costumeId = Math.floor(score / 10) % 10; //更新十位造型\n num4.costumeId = Math.floor(score / 1) % 10; //更新個位造型\n}\n","created_at":"2023-03-14T10:39:24.399+08:00","updated_at":"2023-03-29T13:56:17.349+08:00","name":"登上頂峰 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"javascript","screenshot":{"url":null},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":78,"hashid":"2pdsre6g8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":11532058,"file_name":"fail.mp3","project_id":507124,"asset_id":613806,"created_at":"2023-03-14T10:39:59.445+08:00","updated_at":"2023-03-14T10:39:59.445+08:00"},{"id":11532059,"file_name":"8.png","project_id":507124,"asset_id":613807,"created_at":"2023-03-14T10:39:59.452+08:00","updated_at":"2023-03-14T10:39:59.452+08:00"},{"id":11532060,"file_name":"9.png","project_id":507124,"asset_id":613808,"created_at":"2023-03-14T10:39:59.457+08:00","updated_at":"2023-03-14T10:39:59.457+08:00"},{"id":11532061,"file_name":"3.png","project_id":507124,"asset_id":613809,"created_at":"2023-03-14T10:39:59.463+08:00","updated_at":"2023-03-14T10:39:59.463+08:00"},{"id":11532062,"file_name":"7.png","project_id":507124,"asset_id":613810,"created_at":"2023-03-14T10:39:59.468+08:00","updated_at":"2023-03-14T10:39:59.468+08:00"},{"id":11532063,"file_name":"0.png","project_id":507124,"asset_id":613811,"created_at":"2023-03-14T10:39:59.473+08:00","updated_at":"2023-03-14T10:39:59.473+08:00"},{"id":11532064,"file_name":"6.png","project_id":507124,"asset_id":613812,"created_at":"2023-03-14T10:39:59.478+08:00","updated_at":"2023-03-14T10:39:59.478+08:00"},{"id":11532065,"file_name":"2.png","project_id":507124,"asset_id":613813,"created_at":"2023-03-14T10:39:59.483+08:00","updated_at":"2023-03-14T10:39:59.483+08:00"},{"id":11532066,"file_name":"1.png","project_id":507124,"asset_id":613814,"created_at":"2023-03-14T10:39:59.489+08:00","updated_at":"2023-03-14T10:39:59.489+08:00"},{"id":11532067,"file_name":"5.png","project_id":507124,"asset_id":613815,"created_at":"2023-03-14T10:39:59.495+08:00","updated_at":"2023-03-14T10:39:59.495+08:00"},{"id":11532068,"file_name":"4.png","project_id":507124,"asset_id":613816,"created_at":"2023-03-14T10:39:59.500+08:00","updated_at":"2023-03-14T10:39:59.500+08:00"},{"id":11532069,"file_name":"gameover.png","project_id":507124,"asset_id":613817,"created_at":"2023-03-14T10:39:59.506+08:00","updated_at":"2023-03-14T10:39:59.506+08:00"},{"id":11532070,"file_name":"monster_1.png","project_id":507124,"asset_id":613818,"created_at":"2023-03-14T10:39:59.511+08:00","updated_at":"2023-03-14T10:39:59.511+08:00"},{"id":11532071,"file_name":"p_0.png","project_id":507124,"asset_id":613819,"created_at":"2023-03-14T10:39:59.517+08:00","updated_at":"2023-03-14T10:39:59.517+08:00"},{"id":11532072,"file_name":"p_1.png","project_id":507124,"asset_id":613820,"created_at":"2023-03-14T10:39:59.522+08:00","updated_at":"2023-03-14T10:39:59.522+08:00"},{"id":11532073,"file_name":"p_2.png","project_id":507124,"asset_id":613821,"created_at":"2023-03-14T10:39:59.528+08:00","updated_at":"2023-03-14T10:39:59.528+08:00"},{"id":11532074,"file_name":"monster_0.png","project_id":507124,"asset_id":613822,"created_at":"2023-03-14T10:39:59.533+08:00","updated_at":"2023-03-14T10:39:59.533+08:00"},{"id":11532075,"file_name":"p_3.png","project_id":507124,"asset_id":613823,"created_at":"2023-03-14T10:39:59.538+08:00","updated_at":"2023-03-14T10:39:59.538+08:00"},{"id":11532076,"file_name":"monster_2.png","project_id":507124,"asset_id":613824,"created_at":"2023-03-14T10:39:59.543+08:00","updated_at":"2023-03-14T10:39:59.543+08:00"},{"id":11532077,"file_name":"item_2.png","project_id":507124,"asset_id":613825,"created_at":"2023-03-14T10:39:59.548+08:00","updated_at":"2023-03-14T10:39:59.548+08:00"},{"id":11532078,"file_name":"bg.png","project_id":507124,"asset_id":613826,"created_at":"2023-03-14T10:39:59.558+08:00","updated_at":"2023-03-14T10:39:59.558+08:00"},{"id":11532079,"file_name":"b_22.png","project_id":507124,"asset_id":613827,"created_at":"2023-03-14T10:39:59.563+08:00","updated_at":"2023-03-14T10:39:59.563+08:00"},{"id":11532080,"file_name":"b_3.png","project_id":507124,"asset_id":613828,"created_at":"2023-03-14T10:39:59.586+08:00","updated_at":"2023-03-14T10:39:59.586+08:00"},{"id":11532081,"file_name":"b_4.png","project_id":507124,"asset_id":613829,"created_at":"2023-03-14T10:39:59.592+08:00","updated_at":"2023-03-14T10:39:59.592+08:00"},{"id":11532082,"file_name":"b_5.png","project_id":507124,"asset_id":613830,"created_at":"2023-03-14T10:39:59.597+08:00","updated_at":"2023-03-14T10:39:59.597+08:00"},{"id":11532083,"file_name":"b_0.png","project_id":507124,"asset_id":613831,"created_at":"2023-03-14T10:39:59.602+08:00","updated_at":"2023-03-14T10:39:59.602+08:00"},{"id":11532084,"file_name":"b_1.png","project_id":507124,"asset_id":613832,"created_at":"2023-03-14T10:39:59.607+08:00","updated_at":"2023-03-14T10:39:59.607+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦