{"id":512565,"student_id":2589,"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', 'L12.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\n// 開始新的關卡\nfunction startLevel () {\n life = 3;\n steps = 200;\n ball.hidden = true;\n level.hidden = true;\n for (let i = 0; i \u003c 36; i++) {\n let e = enemies[i];\n e.x = Math.random() * 450 - 600;\n e.y = Math.random() * 450 - 600;\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\n if (steps \u003e 0 \u0026\u0026 e.costumeId \u003c 5) {\n e.move(3, 3);\n e.costumeId = Math.floor(steps / 10) % 2;\n } else {\n e.timer -= 1;\n }\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;\n e.costumeId = 5;\n }\n if (e.timer == -5) {\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;\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;\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 = false; //顯示軍階圖\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}\n\nforever(gameloop); // 不斷執行遊戲迴圈\nlevel.on('click', startLevel); // 點擊等級圖開始關卡","created_at":"2023-03-31T11:07:03.318+08:00","updated_at":"2023-03-31T14:44:07.231+08:00","name":"雪球大戰(完整版)","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/512565/ed11d505e20eeec9706955833cf55bd6.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":79,"hashid":"4y3szqw9n","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":11666727,"file_name":"r7.png","project_id":512565,"asset_id":617056,"created_at":"2023-03-31T14:42:41.807+08:00","updated_at":"2023-03-31T14:42:41.807+08:00"},{"id":11666728,"file_name":"r6.png","project_id":512565,"asset_id":617057,"created_at":"2023-03-31T14:42:41.818+08:00","updated_at":"2023-03-31T14:42:41.818+08:00"},{"id":11666729,"file_name":"r5.png","project_id":512565,"asset_id":617058,"created_at":"2023-03-31T14:42:41.828+08:00","updated_at":"2023-03-31T14:42:41.828+08:00"},{"id":11666730,"file_name":"r4.png","project_id":512565,"asset_id":617059,"created_at":"2023-03-31T14:42:41.837+08:00","updated_at":"2023-03-31T14:42:41.837+08:00"},{"id":11666731,"file_name":"r3.png","project_id":512565,"asset_id":617060,"created_at":"2023-03-31T14:42:41.844+08:00","updated_at":"2023-03-31T14:42:41.844+08:00"},{"id":11666732,"file_name":"r2.png","project_id":512565,"asset_id":617061,"created_at":"2023-03-31T14:42:41.851+08:00","updated_at":"2023-03-31T14:42:41.851+08:00"},{"id":11666733,"file_name":"r1.png","project_id":512565,"asset_id":617062,"created_at":"2023-03-31T14:42:41.858+08:00","updated_at":"2023-03-31T14:42:41.858+08:00"},{"id":11666734,"file_name":"r0.png","project_id":512565,"asset_id":617063,"created_at":"2023-03-31T14:42:41.864+08:00","updated_at":"2023-03-31T14:42:41.864+08:00"},{"id":11666735,"file_name":"r_2.png","project_id":512565,"asset_id":617064,"created_at":"2023-03-31T14:42:41.871+08:00","updated_at":"2023-03-31T14:42:41.871+08:00"},{"id":11666736,"file_name":"r_1.png","project_id":512565,"asset_id":617065,"created_at":"2023-03-31T14:42:41.878+08:00","updated_at":"2023-03-31T14:42:41.878+08:00"},{"id":11666737,"file_name":"r_0.png","project_id":512565,"asset_id":617066,"created_at":"2023-03-31T14:42:41.886+08:00","updated_at":"2023-03-31T14:42:41.886+08:00"},{"id":11666738,"file_name":"g_6.png","project_id":512565,"asset_id":617067,"created_at":"2023-03-31T14:42:41.892+08:00","updated_at":"2023-03-31T14:42:41.892+08:00"},{"id":11666739,"file_name":"g_5.png","project_id":512565,"asset_id":617068,"created_at":"2023-03-31T14:42:41.897+08:00","updated_at":"2023-03-31T14:42:41.897+08:00"},{"id":11666740,"file_name":"g_4.png","project_id":512565,"asset_id":617069,"created_at":"2023-03-31T14:42:41.902+08:00","updated_at":"2023-03-31T14:42:41.902+08:00"},{"id":11666741,"file_name":"g_3.png","project_id":512565,"asset_id":617070,"created_at":"2023-03-31T14:42:41.907+08:00","updated_at":"2023-03-31T14:42:41.907+08:00"},{"id":11666742,"file_name":"g_2.png","project_id":512565,"asset_id":617071,"created_at":"2023-03-31T14:42:41.913+08:00","updated_at":"2023-03-31T14:42:41.913+08:00"},{"id":11666743,"file_name":"g_1.png","project_id":512565,"asset_id":617072,"created_at":"2023-03-31T14:42:41.919+08:00","updated_at":"2023-03-31T14:42:41.919+08:00"},{"id":11666744,"file_name":"g_0.png","project_id":512565,"asset_id":617073,"created_at":"2023-03-31T14:42:41.925+08:00","updated_at":"2023-03-31T14:42:41.925+08:00"},{"id":11666745,"file_name":"ball.png","project_id":512565,"asset_id":617074,"created_at":"2023-03-31T14:42:41.931+08:00","updated_at":"2023-03-31T14:42:41.931+08:00"},{"id":11666746,"file_name":"r12.png","project_id":512565,"asset_id":617075,"created_at":"2023-03-31T14:42:41.938+08:00","updated_at":"2023-03-31T14:42:41.938+08:00"},{"id":11666747,"file_name":"r11.png","project_id":512565,"asset_id":617076,"created_at":"2023-03-31T14:42:41.945+08:00","updated_at":"2023-03-31T14:42:41.945+08:00"},{"id":11666748,"file_name":"r10.png","project_id":512565,"asset_id":617077,"created_at":"2023-03-31T14:42:41.951+08:00","updated_at":"2023-03-31T14:42:41.951+08:00"},{"id":11666749,"file_name":"r9.png","project_id":512565,"asset_id":617078,"created_at":"2023-03-31T14:42:41.958+08:00","updated_at":"2023-03-31T14:42:41.958+08:00"},{"id":11666750,"file_name":"r8.png","project_id":512565,"asset_id":617079,"created_at":"2023-03-31T14:42:41.965+08:00","updated_at":"2023-03-31T14:42:41.965+08:00"},{"id":11666751,"file_name":"L12.png","project_id":512565,"asset_id":617080,"created_at":"2023-03-31T14:42:41.973+08:00","updated_at":"2023-03-31T14:42:41.973+08:00"},{"id":11666752,"file_name":"bg.png","project_id":512565,"asset_id":617081,"created_at":"2023-03-31T14:42:41.978+08:00","updated_at":"2023-03-31T14:42:41.978+08:00"},{"id":11666753,"file_name":"L0.png","project_id":512565,"asset_id":617082,"created_at":"2023-03-31T14:42:41.986+08:00","updated_at":"2023-03-31T14:42:41.986+08:00"},{"id":11666754,"file_name":"L1.png","project_id":512565,"asset_id":617083,"created_at":"2023-03-31T14:42:41.993+08:00","updated_at":"2023-03-31T14:42:41.993+08:00"},{"id":11666755,"file_name":"L2.png","project_id":512565,"asset_id":617084,"created_at":"2023-03-31T14:42:41.999+08:00","updated_at":"2023-03-31T14:42:41.999+08:00"},{"id":11666756,"file_name":"L3.png","project_id":512565,"asset_id":617085,"created_at":"2023-03-31T14:42:42.005+08:00","updated_at":"2023-03-31T14:42:42.005+08:00"},{"id":11666757,"file_name":"L4.png","project_id":512565,"asset_id":617086,"created_at":"2023-03-31T14:42:42.012+08:00","updated_at":"2023-03-31T14:42:42.012+08:00"},{"id":11666758,"file_name":"L5.png","project_id":512565,"asset_id":617087,"created_at":"2023-03-31T14:42:42.018+08:00","updated_at":"2023-03-31T14:42:42.018+08:00"},{"id":11666759,"file_name":"L6.png","project_id":512565,"asset_id":617088,"created_at":"2023-03-31T14:42:42.025+08:00","updated_at":"2023-03-31T14:42:42.025+08:00"},{"id":11666760,"file_name":"L7.png","project_id":512565,"asset_id":617089,"created_at":"2023-03-31T14:42:42.033+08:00","updated_at":"2023-03-31T14:42:42.033+08:00"},{"id":11666761,"file_name":"L8.png","project_id":512565,"asset_id":617090,"created_at":"2023-03-31T14:42:42.040+08:00","updated_at":"2023-03-31T14:42:42.040+08:00"},{"id":11666762,"file_name":"L9.png","project_id":512565,"asset_id":617091,"created_at":"2023-03-31T14:42:42.046+08:00","updated_at":"2023-03-31T14:42:42.046+08:00"},{"id":11666763,"file_name":"L10.png","project_id":512565,"asset_id":617092,"created_at":"2023-03-31T14:42:42.052+08:00","updated_at":"2023-03-31T14:42:42.052+08:00"},{"id":11666764,"file_name":"L11.png","project_id":512565,"asset_id":617093,"created_at":"2023-03-31T14:42:42.058+08:00","updated_at":"2023-03-31T14:42:42.058+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦