{"id":317526,"student_id":10,"content":"setBackdrop('bg.png'); //設定背景\nlet player = createSprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png', 'p_4.png', 'p_5.png'); //玩家\nlet mom = createSprite('dad_0.png', 'dad_1.png'); //鵝媽媽\nlet dad = createSprite('mom_0.png', 'mom_1.png'); //鵝爸爸\nlet info = createSprite('info.png'); //遊戲說明\n\nlet count = 0; //推車\nlet total = 0; //完成數\nlet clock = 0; //遊戲迴圈執行次數\nlet babies = []; //存放所有小鵝的陣列\n\nplayer.moveTo(1000, 450); //移動到出口\nmom.moveTo(200, 200); //移動左上角\ndad.moveTo(200, 700); //移動左下角\n\ninfo.layer = 1; //避免遊戲說明被蓋住\n\n//設定角色圖片水平翻轉屬性\nplayer.rotationStyle = 'flipped';\nmom.rotationStyle = 'flipped';\ndad.rotationStyle = 'flipped';\n\ncreateSound('bgm.mp3');\n\nfor (let i = 0; i \u003c 30; i++) {\n let baby = createSprite('baby_0.png', 'baby_1.png'); //創造鵝寶寶\n baby.x = Math.random() * 800 + 200; //隨機水平位置\n baby.y = Math.random() * 700 + 100; //隨機垂直位置\n baby.rotationStyle = 'flipped'; //圖片水平翻轉屬性\n babies.push(baby); //角色存入陣列中\n}\n\n// 遊戲主迴圈\nfunction gameloop () {\n if (info.hidden) {\n updatePlayer(); //更新玩家\n updateParents(); //更新鵝爸媽\n for (let i = 0; i \u003c 30; i++) {\n updateBaby(babies[i]); //更新鵝寶寶\n }\n aniamtion(); //走路動畫\n checkIsGameover(); //確認遊戲是否結束\n clock++; //紀錄遊戲迴圈執行次數加一\n }\n if (cursor.isDown) {\n info.hidden = true; //隱藏遊戲說明\n }\n}\n\n// 更新叩叮玩家\nfunction updatePlayer () {\n if (player.touched(cursor) == false) {\n player.toward(cursor);\n player.stepForward(6);\n }\n\n if (player.x \u003e 1000 \u0026\u0026 player.y \u003e 300 \u0026\u0026 player.y \u003c 600 \u0026\u0026 count \u003e 0) {\n total += count;\n count = 0;\n createSound('drop.mp3');\n }\n inBox(player); //限制叩叮在柵欄內\n}\n\n// 更新鵝媽媽與鵝爸爸\nfunction updateParents () {\n mom.toward(player);\n mom.stepForward(2);\n if (clock % 200 == 0) dad.toward(player);\n dad.stepForward(4);\n inBox(dad); //限制鵝爸爸在柵欄內\n}\n\n// 更新鵝寶寶\nfunction updateBaby(baby) {\n baby.toward(mom);\n baby.stepForward(2);\n baby.toward(player);\n baby.stepForward(-2);\n\n for (let i = 0; i \u003c 30; i++) {\n baby.toward(babies[i]);\n baby.stepForward(-0.02);\n }\n\n if (player.touched(baby) \u0026\u0026 count \u003c 10) {\n baby.destroy();\n count += 1;\n createSound('pick.mp3');\n }\n inBox(baby); //限制鵝寶寶在柵欄內\n}\n\n// 走路動畫\nfunction aniamtion () {\n // 遊戲迴圈每執行 20 次就切換一次左右腳的圖\n let id = clock % 20 \u003e 10 ? 0: 1;\n player.costumeId = id;\n mom.costumeId = id;\n dad.costumeId = id;\n // 將鵝寶寶逐一取出並切換動畫\n for (let i = 0; i \u003c babies.length; i++) {\n babies[i].costumeId = id;\n }\n\n if (count \u003e= 1) player.costumeId += 2; //數量超過 1 就在造型 2 和 3 之間切換\n if (count == 10) player.costumeId += 2; //數量達到 10 就在造型 4 和 5 之間切換\n}\n\n// 確認遊戲是否結束\nfunction checkIsGameover () {\n // 如果碰到鵝媽媽或鵝爸爸\n if (player.touched(mom) || player.touched(dad)) {\n createSprite('fail.png'); //顯示失敗圖\n stop(); //停止遊戲\n createSound('fail.mp3'); //播放失敗音效\n }\n\n // 如果時間到了\n if (clock \u003e= 3600) {\n createSprite('timesup.png'); //顯示時間到圖\n stop(); //停止遊戲\n createSound('fail.mp3'); //播放失敗音效\n }\n\n // 如果收集到 30 隻鵝寶寶\n if (total == 30) {\n createSprite('success.png'); //顯示獲勝圖\n stop(); //停止遊戲\n createSound('win.mp3'); //播放獲勝音效\n }\n}\n\n// 限制角色在柵欄內\nfunction inBox (s) {\n if (s.x \u003e 1100) s.x = 1100; //防止超過右邊邊界\n if (s.y \u003e 800) s.y = 800; //防止超過下方邊界\n if (s.x \u003c 100) s.x = 100; //防止超過左邊邊界\n if (s.y \u003c 100) s.y = 100; //防止超過上方邊界\n}\n\nforever(gameloop); //重複不斷執行遊戲迴圈","created_at":"2021-11-22T15:35:12.320+08:00","updated_at":"2022-08-23T20:30:21.430+08:00","name":"叩叮捉小鵝(完整版)","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/317526/d2fdcfe6a52c016dc2e1f6b4e1a1a538.jpg"},"parent_id":2,"plugin":"Game.set({\n width: 1200, height: 900\n})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":281,"hashid":"kdms6egzg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":6565881,"file_name":"p_2.png","project_id":317526,"asset_id":441199,"created_at":"2021-11-22T15:35:24.983+08:00","updated_at":"2021-11-22T15:35:24.983+08:00"},{"id":6565882,"file_name":"p_1.png","project_id":317526,"asset_id":441200,"created_at":"2021-11-22T15:35:24.987+08:00","updated_at":"2021-11-22T15:35:24.987+08:00"},{"id":6565883,"file_name":"p_0.png","project_id":317526,"asset_id":441201,"created_at":"2021-11-22T15:35:24.991+08:00","updated_at":"2021-11-22T15:35:24.991+08:00"},{"id":6565885,"file_name":"fail.png","project_id":317526,"asset_id":441203,"created_at":"2021-11-22T15:35:25.002+08:00","updated_at":"2021-11-22T15:35:25.002+08:00"},{"id":6565886,"file_name":"bg.png","project_id":317526,"asset_id":441204,"created_at":"2021-11-22T15:35:25.006+08:00","updated_at":"2021-11-22T15:35:25.006+08:00"},{"id":6565887,"file_name":"baby_1.png","project_id":317526,"asset_id":441205,"created_at":"2021-11-22T15:35:25.010+08:00","updated_at":"2021-11-22T15:35:25.010+08:00"},{"id":6565888,"file_name":"baby_0.png","project_id":317526,"asset_id":441206,"created_at":"2021-11-22T15:35:25.017+08:00","updated_at":"2021-11-22T15:35:25.017+08:00"},{"id":6565867,"file_name":"win.mp3","project_id":317526,"asset_id":441185,"created_at":"2021-11-22T15:35:24.825+08:00","updated_at":"2021-11-22T15:35:24.825+08:00"},{"id":6565868,"file_name":"fail.mp3","project_id":317526,"asset_id":441186,"created_at":"2021-11-22T15:35:24.829+08:00","updated_at":"2021-11-22T15:35:24.829+08:00"},{"id":6565869,"file_name":"dad_1.png","project_id":317526,"asset_id":441187,"created_at":"2021-11-22T15:35:24.833+08:00","updated_at":"2021-11-22T15:35:24.833+08:00"},{"id":6565870,"file_name":"mom_1.png","project_id":317526,"asset_id":441188,"created_at":"2021-11-22T15:35:24.837+08:00","updated_at":"2021-11-22T15:35:24.837+08:00"},{"id":6565871,"file_name":"mom_0.png","project_id":317526,"asset_id":441189,"created_at":"2021-11-22T15:35:24.841+08:00","updated_at":"2021-11-22T15:35:24.841+08:00"},{"id":6565872,"file_name":"dad_0.png","project_id":317526,"asset_id":441190,"created_at":"2021-11-22T15:35:24.845+08:00","updated_at":"2021-11-22T15:35:24.845+08:00"},{"id":6565873,"file_name":"pick.mp3","project_id":317526,"asset_id":441191,"created_at":"2021-11-22T15:35:24.849+08:00","updated_at":"2021-11-22T15:35:24.849+08:00"},{"id":6565874,"file_name":"drop.mp3","project_id":317526,"asset_id":441192,"created_at":"2021-11-22T15:35:24.852+08:00","updated_at":"2021-11-22T15:35:24.852+08:00"},{"id":6565875,"file_name":"bgm.mp3","project_id":317526,"asset_id":441193,"created_at":"2021-11-22T15:35:24.950+08:00","updated_at":"2021-11-22T15:35:24.950+08:00"},{"id":6565876,"file_name":"timesup.png","project_id":317526,"asset_id":441194,"created_at":"2021-11-22T15:35:24.961+08:00","updated_at":"2021-11-22T15:35:24.961+08:00"},{"id":6565877,"file_name":"success.png","project_id":317526,"asset_id":441195,"created_at":"2021-11-22T15:35:24.966+08:00","updated_at":"2021-11-22T15:35:24.966+08:00"},{"id":6565878,"file_name":"p_5.png","project_id":317526,"asset_id":441196,"created_at":"2021-11-22T15:35:24.969+08:00","updated_at":"2021-11-22T15:35:24.969+08:00"},{"id":6565879,"file_name":"p_4.png","project_id":317526,"asset_id":441197,"created_at":"2021-11-22T15:35:24.974+08:00","updated_at":"2021-11-22T15:35:24.974+08:00"},{"id":6565880,"file_name":"p_3.png","project_id":317526,"asset_id":441198,"created_at":"2021-11-22T15:35:24.978+08:00","updated_at":"2021-11-22T15:35:24.978+08:00"},{"id":9609645,"file_name":"info.png","project_id":317526,"asset_id":557430,"created_at":"2022-08-23T13:25:44.950+08:00","updated_at":"2022-08-23T13:25:44.950+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦