{"id":605855,"student_id":1444,"content":"setBackdrop('bg.png'); //設定背景\nlet player = createSprite('r_0.png', 'r_1.png', 'r_2.png'); //玩家\nlet ball = createSprite('ball.png'); //玩家雪球\nlet level = createSprite('L0.png', 'L1.png', 'L2.png', 'L3.png', 'L4.png', 'L5.png', 'L6.png', 'L7.png', 'L8.png', 'L9.png', 'L10.png', 'L11.png'); //開始\nlet ranks = createSprite('r0.png', 'r1.png', 'r2.png', 'r3.png', 'r4.png', 'r5.png', 'r6.png', 'r7.png', 'r8.png', 'r9.png', 'r10.png', 'r11.png', 'r12.png'); //官階\nlet enemies = []; //存放敵人角色\nlet balls = []; //存放敵人雪球\nlet life = 3; //玩家血量\nlet steps = 200; //進場步數\n\nlevel.layer = 1000; //設定圖層最上\nranks.layer = 1000; //設定圖層第二\nplayer.layer = 999; //設定圖層第三\nball.layer = 998; //設定圖層第四\nranks.hidden = true; //隱藏軍階圖\nball.hidden = true; //隱藏玩家雪球\n\n// 創造 36 個敵人\nfor (let i = 0; i \u003c 36; i++) {\n let e = createSprite('g_0.png', 'g_1.png', 'g_2.png', 'g_3.png', 'g_4.png', 'g_5.png', 'g_6.png');\n e.rotationStyle = ('fixed');\n enemies.push(e);\n}\n\nlevel.on('click', startLevel); // 點擊等級圖開始關卡\nforever(gameloop); // 不斷執行遊戲迴圈\n\n// 開始新的關卡\nfunction startLevel () {\n life = 3; //恢復玩家血量\n ball.hidden = true; //隱藏玩家雪球\n level.hidden = true; //隱藏關卡圖\n steps = 200;\n for (let i = 0; i \u003c 36; i++) {\n let e = enemies[i];\n e.x = Math.random() * 450-600; // 隨機設定 x 座標\n e.y = Math.random() * 450-600; // 隨機設定 y 座標\n e.costumeId = 0; //恢復造型\n e.direction = Math.floor(Math.random() * 4) * 90 + 45; //設定敵人移動方向\n e.timer = Math.floor(Math.random() * 180) + 180; //設定敵人計時器\n e.hidden = i \u003e= level.costumeId * 3 + 3; //根據關卡顯示敵人數量\n }\n}\n\n// 遊戲迴圈\nfunction gameloop () {\n // 如果遊戲開始圖和軍階圖隱藏,才會更新角色\n if (level.hidden \u0026\u0026 ranks.hidden) {\n updatePlayer(); // 更新玩家\n enemies.forEach(updateEnemy); // 更新敵人\n balls.forEach(updateBall); // 更新敵人的雪球\n checkIsGameover(); // 檢查遊戲使否結束\n steps -= 1;\n }\n if (level.y \u003c 450) level.y += 20; //向下滑動\n if (ranks.y \u003c 450) ranks.y += 20; //向下滑動\n}\n\n// 更新玩家\nfunction updatePlayer () {\n if (cursor.x + cursor.y \u003e 1200) {\n player.moveTo(cursor); //跟著滑鼠移動\n }\n\n if (cursor.isDown) {\n player.costumeId = 1; //準備雪球造型\n ball.moveTo(player); //移動雪球至玩家所在\n ball.hidden = false; //顯示雪球\n } else {\n player.costumeId = 0; //恢復造型\n ball.move(-20, -20); //玩家雪球不斷向左上移動\n }\n}\n\n// 更新敵人\nfunction updateEnemy (e) {\n\nif (steps \u003e 0) {\ne.move(3,3);\n}else{\n e.timer -= 1; //敵人計時器倒數\n}\n if (steps \u003c 0 \u0026\u0026 e.timer \u003e 180) {\n e.stepForward(3); // 走路\n e.costumeId = Math.floor(e.timer / 10) % 2; // 走路動畫\n }\n if (e.timer == 180) {\n e.costumeId = 2; // 準備雪球\n }\n if (e.timer == 120) {\n e.costumeId = 3; // 瞄準\n }\n if (e.timer == 60 \u0026\u0026 e.hidden == false) {\n e.costumeId = 4; // 丟出雪球\n createBall(e.x, e.y);\n }\n if (e.timer == 0) {\n e.timer = Math.floor(Math.random() * 200) + 180; //設定計時器\n e.direction = Math.floor(Math.random() * 4) * 90 + 45; //隨機方向\n }\n // 如果超出邊界就反轉\n if (e.x \u003c 0 || e.y \u003c 0 || e.x + e.y \u003e 900) {\n e.direction += 180;\n }\n // 如果碰到玩家雪球而且還站著\n if (e.touched(ball) \u0026\u0026 e.costumeId \u003c 5) {\n ball.hidden = true; //隱藏玩家雪球\n e.timer = -1; //計時器設定 -1\n e.costumeId = 5; //變成倒一半的圖\n }\n if (e.timer == -8) {\n e.costumeId = 6; //變成完全倒地的圖\n }\n\n e.layer = e.y; // 角色越下面圖層越上層\n if (e.costumeId == 6) e.layer -= 200; // 降低暈倒的叩叮圖層\n}\n\n// 更新敵人雪球\nfunction updateBall (b) {\n b.move(10, 10); //向右下角移動\n if (b.x \u003e 1200 || b.y \u003e 900) {\n b.destroy(); //超出邊界就移除角色\n }\n if (b.touched(player)) {\n b.destroy(); //移除角色\n life -= 1; //玩家血量 -1\n }\n}\n\n// 檢查遊戲是否結束\nfunction checkIsGameover () {\n let count = 0; //紀錄隱藏或倒地的敵人數量\n for (let i = 0; i \u003c 36; i++) {\n if (enemies[i].hidden || enemies[i].costumeId == 6) {\n count += 1; //敵人隱藏或暈倒計數 +1\n }\n }\n if (count == 36) win(); //關卡獲勝\n if (life \u003c= 0) gameover(); //遊戲結束\n}\n\n// 該關卡獲勝\nfunction win () {\n level.costumeId += 1; //關卡等級切換下個造型\n level.hidden = false; //顯使關卡等級\n level.y = -450; //初始化滑入位置\n if (level.costumeId == 12) gameover(); // 最高等級就結束遊戲\n}\n\n// 遊戲失敗\nfunction gameover () {\n player.costumeId = 2; //切換倒地造型\n ranks.hidden = true; //顯示軍階圖\n ranks.costumeId = level.costumeId; //根據等級切換軍階\n ranks.y = -450; //初始化滑入位置\n}\n\n// 創造敵人雪球\nfunction createBall (x, y) {\n let ball = createSprite('ball.png'); //創造敵人雪球\n ball.moveTo(x, y); //移動到發射雪球的位置\n balls.push(ball); //放到敵人雪球陣列中\n}","created_at":"2023-09-05T21:23:37.125+08:00","updated_at":"2023-09-05T22:30:22.504+08:00","name":"雪球大戰(除錯預設版) 副本","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/605855/cadb71277d8c68401126ca1d3dce45d3.jpg"},"parent_id":512550,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":32,"hashid":"36ysydz85","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":13650921,"file_name":"r7.png","project_id":605855,"asset_id":616954,"created_at":"2023-09-05T21:23:37.134+08:00","updated_at":"2023-09-05T21:23:37.134+08:00"},{"id":13650922,"file_name":"r6.png","project_id":605855,"asset_id":616955,"created_at":"2023-09-05T21:23:37.137+08:00","updated_at":"2023-09-05T21:23:37.137+08:00"},{"id":13650923,"file_name":"r5.png","project_id":605855,"asset_id":616956,"created_at":"2023-09-05T21:23:37.139+08:00","updated_at":"2023-09-05T21:23:37.139+08:00"},{"id":13650924,"file_name":"r4.png","project_id":605855,"asset_id":616957,"created_at":"2023-09-05T21:23:37.140+08:00","updated_at":"2023-09-05T21:23:37.140+08:00"},{"id":13650925,"file_name":"r3.png","project_id":605855,"asset_id":616958,"created_at":"2023-09-05T21:23:37.142+08:00","updated_at":"2023-09-05T21:23:37.142+08:00"},{"id":13650926,"file_name":"r2.png","project_id":605855,"asset_id":616959,"created_at":"2023-09-05T21:23:37.144+08:00","updated_at":"2023-09-05T21:23:37.144+08:00"},{"id":13650927,"file_name":"r1.png","project_id":605855,"asset_id":616960,"created_at":"2023-09-05T21:23:37.145+08:00","updated_at":"2023-09-05T21:23:37.145+08:00"},{"id":13650928,"file_name":"r0.png","project_id":605855,"asset_id":616961,"created_at":"2023-09-05T21:23:37.147+08:00","updated_at":"2023-09-05T21:23:37.147+08:00"},{"id":13650929,"file_name":"r_2.png","project_id":605855,"asset_id":616962,"created_at":"2023-09-05T21:23:37.148+08:00","updated_at":"2023-09-05T21:23:37.148+08:00"},{"id":13650930,"file_name":"r_1.png","project_id":605855,"asset_id":616963,"created_at":"2023-09-05T21:23:37.150+08:00","updated_at":"2023-09-05T21:23:37.150+08:00"},{"id":13650931,"file_name":"r_0.png","project_id":605855,"asset_id":616964,"created_at":"2023-09-05T21:23:37.152+08:00","updated_at":"2023-09-05T21:23:37.152+08:00"},{"id":13650932,"file_name":"g_6.png","project_id":605855,"asset_id":616965,"created_at":"2023-09-05T21:23:37.153+08:00","updated_at":"2023-09-05T21:23:37.153+08:00"},{"id":13650933,"file_name":"g_5.png","project_id":605855,"asset_id":616966,"created_at":"2023-09-05T21:23:37.154+08:00","updated_at":"2023-09-05T21:23:37.154+08:00"},{"id":13650934,"file_name":"g_4.png","project_id":605855,"asset_id":616967,"created_at":"2023-09-05T21:23:37.156+08:00","updated_at":"2023-09-05T21:23:37.156+08:00"},{"id":13650935,"file_name":"g_3.png","project_id":605855,"asset_id":616968,"created_at":"2023-09-05T21:23:37.157+08:00","updated_at":"2023-09-05T21:23:37.157+08:00"},{"id":13650936,"file_name":"g_2.png","project_id":605855,"asset_id":616969,"created_at":"2023-09-05T21:23:37.158+08:00","updated_at":"2023-09-05T21:23:37.158+08:00"},{"id":13650937,"file_name":"g_1.png","project_id":605855,"asset_id":616970,"created_at":"2023-09-05T21:23:37.160+08:00","updated_at":"2023-09-05T21:23:37.160+08:00"},{"id":13650938,"file_name":"g_0.png","project_id":605855,"asset_id":616971,"created_at":"2023-09-05T21:23:37.161+08:00","updated_at":"2023-09-05T21:23:37.161+08:00"},{"id":13650939,"file_name":"ball.png","project_id":605855,"asset_id":616972,"created_at":"2023-09-05T21:23:37.163+08:00","updated_at":"2023-09-05T21:23:37.163+08:00"},{"id":13650940,"file_name":"r12.png","project_id":605855,"asset_id":616973,"created_at":"2023-09-05T21:23:37.165+08:00","updated_at":"2023-09-05T21:23:37.165+08:00"},{"id":13650941,"file_name":"r11.png","project_id":605855,"asset_id":616974,"created_at":"2023-09-05T21:23:37.166+08:00","updated_at":"2023-09-05T21:23:37.166+08:00"},{"id":13650942,"file_name":"r10.png","project_id":605855,"asset_id":616975,"created_at":"2023-09-05T21:23:37.167+08:00","updated_at":"2023-09-05T21:23:37.167+08:00"},{"id":13650943,"file_name":"r9.png","project_id":605855,"asset_id":616976,"created_at":"2023-09-05T21:23:37.169+08:00","updated_at":"2023-09-05T21:23:37.169+08:00"},{"id":13650944,"file_name":"r8.png","project_id":605855,"asset_id":616977,"created_at":"2023-09-05T21:23:37.171+08:00","updated_at":"2023-09-05T21:23:37.171+08:00"},{"id":13650945,"file_name":"L12.png","project_id":605855,"asset_id":616978,"created_at":"2023-09-05T21:23:37.172+08:00","updated_at":"2023-09-05T21:23:37.172+08:00"},{"id":13650946,"file_name":"bg.png","project_id":605855,"asset_id":616979,"created_at":"2023-09-05T21:23:37.173+08:00","updated_at":"2023-09-05T21:23:37.173+08:00"},{"id":13650947,"file_name":"L0.png","project_id":605855,"asset_id":616980,"created_at":"2023-09-05T21:23:37.175+08:00","updated_at":"2023-09-05T21:23:37.175+08:00"},{"id":13650948,"file_name":"L1.png","project_id":605855,"asset_id":616981,"created_at":"2023-09-05T21:23:37.176+08:00","updated_at":"2023-09-05T21:23:37.176+08:00"},{"id":13650949,"file_name":"L2.png","project_id":605855,"asset_id":616982,"created_at":"2023-09-05T21:23:37.177+08:00","updated_at":"2023-09-05T21:23:37.177+08:00"},{"id":13650950,"file_name":"L3.png","project_id":605855,"asset_id":616983,"created_at":"2023-09-05T21:23:37.179+08:00","updated_at":"2023-09-05T21:23:37.179+08:00"},{"id":13650951,"file_name":"L4.png","project_id":605855,"asset_id":616984,"created_at":"2023-09-05T21:23:37.180+08:00","updated_at":"2023-09-05T21:23:37.180+08:00"},{"id":13650952,"file_name":"L5.png","project_id":605855,"asset_id":616985,"created_at":"2023-09-05T21:23:37.181+08:00","updated_at":"2023-09-05T21:23:37.181+08:00"},{"id":13650953,"file_name":"L6.png","project_id":605855,"asset_id":616986,"created_at":"2023-09-05T21:23:37.182+08:00","updated_at":"2023-09-05T21:23:37.182+08:00"},{"id":13650954,"file_name":"L7.png","project_id":605855,"asset_id":616987,"created_at":"2023-09-05T21:23:37.184+08:00","updated_at":"2023-09-05T21:23:37.184+08:00"},{"id":13650955,"file_name":"L8.png","project_id":605855,"asset_id":616988,"created_at":"2023-09-05T21:23:37.185+08:00","updated_at":"2023-09-05T21:23:37.185+08:00"},{"id":13650956,"file_name":"L9.png","project_id":605855,"asset_id":616989,"created_at":"2023-09-05T21:23:37.186+08:00","updated_at":"2023-09-05T21:23:37.186+08:00"},{"id":13650957,"file_name":"L10.png","project_id":605855,"asset_id":616990,"created_at":"2023-09-05T21:23:37.188+08:00","updated_at":"2023-09-05T21:23:37.188+08:00"},{"id":13650958,"file_name":"L11.png","project_id":605855,"asset_id":616991,"created_at":"2023-09-05T21:23:37.189+08:00","updated_at":"2023-09-05T21:23:37.189+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦