{"id":460891,"student_id":10,"content":"createSprite('cover.png'); //設定背景圖\nlet player = createSprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png', '10.png'); //企鵝\nlet item = createSprite('item_0.png', 'item_1.png', 'item_2.png', 'item_3.png'); //拋出物品\nlet number = createSprite('n_1.png', 'n_2.png', 'n_3.png', 'n_4.png', 'n_5.png'); //倒數數字\nlet info = createSprite('info.png', 'next.png', 'end.png'); //遊戲說明、下個關卡、遊戲結束\nlet sight = createSprite('target.png'); //準星\n\nlet blocks = []; //存放冰塊角色的陣列\nlet level = 0; //等級\nlet timer = 0; //計時器\nlet target; //目標冰塊\nlet vy = 0; //物品下降速度\nlet count = 0; //紅寶石數量\nlet score = 0; //金塊數量\nlet clock = 0; //動畫計時器\n\nfor (let y = 0; y \u003c 6; y++) {\n for (let x = 0; x \u003c 10; x++) {\n let b = createSprite('b_0.png', 'b_1.png', 'b_2.png', 'b_3.png', 'b_4.png', 'b_4.png', 'b_4.png', 'b_4.png');\n b.x = x * 100 + 150;\n b.y = y * 100 + 150;\n if (x % 2 == 0) b.y -= 50;\n b.layer = -1;\n b.on('click', function () {\n if (b.costumeId \u003e 3 \u0026\u0026 timer \u003c 900) {\n target = b;\n }\n });\n blocks.push(b);\n }\n}\n\nplayer.rotationStyle = 'fixed';\nnumber.opacity = 0.3;\n\n//開始每個關卡\nfunction startLevel () {\n level += 1; //每進入一個關卡等級 +1\n count = 0; //紅寶石數量歸零\n timer = 1200; //重置計時器\n target = null; //取消目標物\n info.hidden = true; //隱藏說明\n player.moveTo(600, 450); //重置玩家企鵝\n item.moveTo(600, 1000); //移動到畫面外\n // 重置所有的冰塊造型\n for (let i = 0; i \u003c 60; i++) {\n blocks[i].costumeId = 0;\n if (i \u003c 17) blocks[i].costumeId = 1;\n else if (i \u003c 20) blocks[i].costumeId = 3;\n else if (i \u003c 20 + level) blocks[i].costumeId = 2;\n }\n shuffle(); //隨機切換冰塊造型\n}\n\n//冰塊隨機互換\nfunction shuffle () {\n for (let i = 0; i \u003c 100; i++) {\n let randA = Math.floor(Math.random() * 60);\n let randB = Math.floor(Math.random() * 60);\n let a = blocks[randA].costumeId; //隨機取出 A 冰塊的造型編號\n let b = blocks[randB].costumeId; //隨機取出 B 冰塊的造型編號\n blocks[randA].costumeId = b; //交換造型編號\n blocks[randB].costumeId = a; //交換造型編號\n }\n}\n\nfunction gameloop () {\n sight.moveTo(cursor); //準星不斷跟著滑鼠移動\n if (info.hidden) {\n updateTimer(); //更新計時器\n updatePlayer(); //更新企鵝角色\n updateitem(); //更新寶石\n updateTexts(); //引出計分板文字\n }\n}\n\nfunction updatePlayer () {\n if (target != undefined) {\n player.toward(target); //朝向目標\n player.stepForward(6); //向前移動\n player.costumeId = Math.floor(timer / 12) % 2; //走路動畫\n player.costumeId += Math.floor(player.direction / 90) * 2; //根據方向切換造型\n if (player.distanceTo(target) \u003c 6) {\n item.moveTo(player); //移動到玩家所在\n item.costumeId = target.costumeId; //拋出的角色造型設定\n vy = -10; //拋物線\n target.costumeId -= 4; //翻開冰塊\n if (target.costumeId == 1) score += 1; //挖到金塊\n if (target.costumeId == 2) count += 1; //挖到紅寶石\n if (target.costumeId == 3) {\n //挖到炸彈\n count = 0; //紅寶石歸ㄌㄧㄥ\n timer = 0; //時間歸零\n player.costumeId = 10; //變成烤焦造型\n }\n vy = -10; //拋物線\n clock = 20; //動畫時間\n target = undefined; //清空目標\n }\n }\n //挖冰塊的動畫\n if (player.costumeId != 10) {\n clock -= 1;\n if (clock \u003e 10) player.costumeId = 8; //挖下動作\n else if (clock \u003e 0) player.costumeId = 9; //挖起動作\n }\n}\n\n//更新計時器\nfunction updateTimer () {\n if (timer \u003e 0) timer -= 1; //時間減少 1\n if (timer == 0) timeout(); //時間到\n if (timer == 900) hideAll(); //蓋上冰塊\n number.costumeId = Math.floor(timer / 60) % 5; //切換倒數數字造型\n number.hidden = 300 \u003c= timer \u0026\u0026 timer \u003c= 900; //顯示倒數數字\n}\n\n//時間到\nfunction timeout () {\n info.hidden = false; //顯示說明\n info.costumeId = count == level ? 1: 2;\n}\n\n//隱藏全部寶石\nfunction hideAll () {\n for (let i = 0; i \u003c 60; i++) {\n blocks[i].costumeId += 4; //蓋上冰塊\n }\n}\n\n//更新拋出的物品\nfunction updateitem () {\n vy += 0.5; //向下速度增加\n item.y += vy; //改變垂直 y 座標\n item.direction += 10; //旋轉\n}\n\n//顯示計分板上的文字\nfunction updateTexts () {\n drawText(Math.floor(timer / 60), 250, 830, 'white', 50); //剩餘時間\n drawText(score, 650, 830, 'white', 50); //金塊數量\n drawText(count, 1050, 830, 'white', 50); //紅寶石數量\n}\n\n//點擊遊戲說明圖\nfunction infoOnClick () {\n if (info.costumeId == 2) {\n let result = createSprite('end_0.png', 'end_1.png', 'end_2.png', 'end_3.png', 'end_4.png', 'end_5.png'); //創造企鵝解鎖圖\n result.costumeId = Math.floor(score / 10); //根據分數切換解鎖等級\n if (result.costumeId \u003e 5) result.costumeId = 5; //最高只能解鎖至最後一張\n info.destroy(); //隱藏說明圖\n } else {\n startLevel(); //開始新的一局\n }\n}\n\nforever(gameloop);\ninfo.on('click', infoOnClick);","created_at":"2022-11-16T09:57:43.596+08:00","updated_at":"2024-01-15T23:36:54.510+08:00","name":"企鵝挖寶(完整版) (1)","language":"javascript","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/460891/c9e338ebcd4ebabe083938d093800ca9.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900});","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":123,"hashid":"4y3szwmz3","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10460824,"file_name":"item_0.png","project_id":460891,"asset_id":582232,"created_at":"2022-11-16T09:57:55.257+08:00","updated_at":"2022-11-16T09:57:55.257+08:00"},{"id":10460825,"file_name":"10.png","project_id":460891,"asset_id":582233,"created_at":"2022-11-16T09:57:55.267+08:00","updated_at":"2022-11-16T09:57:55.267+08:00"},{"id":10460826,"file_name":"9.png","project_id":460891,"asset_id":582234,"created_at":"2022-11-16T09:57:55.277+08:00","updated_at":"2022-11-16T09:57:55.277+08:00"},{"id":10460827,"file_name":"8.png","project_id":460891,"asset_id":582235,"created_at":"2022-11-16T09:57:55.286+08:00","updated_at":"2022-11-16T09:57:55.286+08:00"},{"id":10460828,"file_name":"3.png","project_id":460891,"asset_id":582236,"created_at":"2022-11-16T09:57:55.294+08:00","updated_at":"2022-11-16T09:57:55.294+08:00"},{"id":10460829,"file_name":"5.png","project_id":460891,"asset_id":582237,"created_at":"2022-11-16T09:57:55.303+08:00","updated_at":"2022-11-16T09:57:55.303+08:00"},{"id":10460830,"file_name":"2.png","project_id":460891,"asset_id":582238,"created_at":"2022-11-16T09:57:55.309+08:00","updated_at":"2022-11-16T09:57:55.309+08:00"},{"id":10460831,"file_name":"4.png","project_id":460891,"asset_id":582239,"created_at":"2022-11-16T09:57:55.316+08:00","updated_at":"2022-11-16T09:57:55.316+08:00"},{"id":10460832,"file_name":"1.png","project_id":460891,"asset_id":582240,"created_at":"2022-11-16T09:57:55.324+08:00","updated_at":"2022-11-16T09:57:55.324+08:00"},{"id":10460833,"file_name":"7.png","project_id":460891,"asset_id":582241,"created_at":"2022-11-16T09:57:55.332+08:00","updated_at":"2022-11-16T09:57:55.332+08:00"},{"id":10460834,"file_name":"0.png","project_id":460891,"asset_id":582242,"created_at":"2022-11-16T09:57:55.339+08:00","updated_at":"2022-11-16T09:57:55.339+08:00"},{"id":10460835,"file_name":"6.png","project_id":460891,"asset_id":582243,"created_at":"2022-11-16T09:57:55.345+08:00","updated_at":"2022-11-16T09:57:55.345+08:00"},{"id":10460836,"file_name":"gameover.png","project_id":460891,"asset_id":582244,"created_at":"2022-11-16T09:57:55.353+08:00","updated_at":"2022-11-16T09:57:55.353+08:00"},{"id":10460837,"file_name":"end.png","project_id":460891,"asset_id":582245,"created_at":"2022-11-16T09:57:55.360+08:00","updated_at":"2022-11-16T09:57:55.360+08:00"},{"id":10460838,"file_name":"end_5.png","project_id":460891,"asset_id":582246,"created_at":"2022-11-16T09:57:55.370+08:00","updated_at":"2022-11-16T09:57:55.370+08:00"},{"id":10460839,"file_name":"end_4.png","project_id":460891,"asset_id":582247,"created_at":"2022-11-16T09:57:55.378+08:00","updated_at":"2022-11-16T09:57:55.378+08:00"},{"id":10460840,"file_name":"end_3.png","project_id":460891,"asset_id":582248,"created_at":"2022-11-16T09:57:55.386+08:00","updated_at":"2022-11-16T09:57:55.386+08:00"},{"id":10460841,"file_name":"end_2.png","project_id":460891,"asset_id":582249,"created_at":"2022-11-16T09:57:55.394+08:00","updated_at":"2022-11-16T09:57:55.394+08:00"},{"id":10460842,"file_name":"end_1.png","project_id":460891,"asset_id":582250,"created_at":"2022-11-16T09:57:55.401+08:00","updated_at":"2022-11-16T09:57:55.401+08:00"},{"id":10460843,"file_name":"end_0.png","project_id":460891,"asset_id":582251,"created_at":"2022-11-16T09:57:55.410+08:00","updated_at":"2022-11-16T09:57:55.410+08:00"},{"id":10460844,"file_name":"b_4.png","project_id":460891,"asset_id":582252,"created_at":"2022-11-16T09:57:55.417+08:00","updated_at":"2022-11-16T09:57:55.417+08:00"},{"id":10460845,"file_name":"b_0.png","project_id":460891,"asset_id":582253,"created_at":"2022-11-16T09:57:55.423+08:00","updated_at":"2022-11-16T09:57:55.423+08:00"},{"id":10460846,"file_name":"b_2.png","project_id":460891,"asset_id":582254,"created_at":"2022-11-16T09:57:55.431+08:00","updated_at":"2022-11-16T09:57:55.431+08:00"},{"id":10460847,"file_name":"b_1.png","project_id":460891,"asset_id":582255,"created_at":"2022-11-16T09:57:55.465+08:00","updated_at":"2022-11-16T09:57:55.465+08:00"},{"id":10460848,"file_name":"b_3.png","project_id":460891,"asset_id":582256,"created_at":"2022-11-16T09:57:55.472+08:00","updated_at":"2022-11-16T09:57:55.472+08:00"},{"id":10460849,"file_name":"board.png","project_id":460891,"asset_id":582257,"created_at":"2022-11-16T09:57:55.479+08:00","updated_at":"2022-11-16T09:57:55.479+08:00"},{"id":10460850,"file_name":"item_3.png","project_id":460891,"asset_id":582258,"created_at":"2022-11-16T09:57:55.485+08:00","updated_at":"2022-11-16T09:57:55.485+08:00"},{"id":10460851,"file_name":"item_1.png","project_id":460891,"asset_id":582259,"created_at":"2022-11-16T09:57:55.492+08:00","updated_at":"2022-11-16T09:57:55.492+08:00"},{"id":10460852,"file_name":"item_2.png","project_id":460891,"asset_id":582260,"created_at":"2022-11-16T09:57:55.498+08:00","updated_at":"2022-11-16T09:57:55.498+08:00"},{"id":10460853,"file_name":"info.png","project_id":460891,"asset_id":582261,"created_at":"2022-11-16T09:57:55.507+08:00","updated_at":"2022-11-16T09:57:55.507+08:00"},{"id":10460854,"file_name":"n_1.png","project_id":460891,"asset_id":582262,"created_at":"2022-11-16T09:57:55.514+08:00","updated_at":"2022-11-16T09:57:55.514+08:00"},{"id":10460855,"file_name":"n_2.png","project_id":460891,"asset_id":582263,"created_at":"2022-11-16T09:57:55.522+08:00","updated_at":"2022-11-16T09:57:55.522+08:00"},{"id":10460856,"file_name":"n_3.png","project_id":460891,"asset_id":582264,"created_at":"2022-11-16T09:57:55.528+08:00","updated_at":"2022-11-16T09:57:55.528+08:00"},{"id":10460857,"file_name":"n_4.png","project_id":460891,"asset_id":582265,"created_at":"2022-11-16T09:57:55.535+08:00","updated_at":"2022-11-16T09:57:55.535+08:00"},{"id":10460858,"file_name":"n_5.png","project_id":460891,"asset_id":582266,"created_at":"2022-11-16T09:57:55.543+08:00","updated_at":"2022-11-16T09:57:55.543+08:00"},{"id":10460859,"file_name":"next.png","project_id":460891,"asset_id":582267,"created_at":"2022-11-16T09:57:55.551+08:00","updated_at":"2022-11-16T09:57:55.551+08:00"},{"id":10460860,"file_name":"target.png","project_id":460891,"asset_id":582268,"created_at":"2022-11-16T09:57:55.558+08:00","updated_at":"2022-11-16T09:57:55.558+08:00"},{"id":10460861,"file_name":"cover.png","project_id":460891,"asset_id":582269,"created_at":"2022-11-16T09:57:55.566+08:00","updated_at":"2022-11-16T09:57:55.566+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦