{"id":235770,"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(\"mom_0.png\", \"mom_1.png\"); //鵝媽媽\nlet dad = createSprite(\"dad_0.png\", \"dad_1.png\"); //鵝爸爸\nlet info = createSprite(\"info.png\"); //遊戲說明\n\nlet babies = []; //存放所有小鵝的陣列\nlet count = 0; //推車\nlet total = 0; //完成數\nlet clock = 0; //遊戲迴圈執行次數\n\nplayer.moveTo(800, 450);\nmom.moveTo(400, 300);\ndad.moveTo(400, 600);\n\ninfo.layer = 1; //避免遊戲說明被蓋住\n// info.hidden = true; //暫時隱藏遊戲說明\n\nplayer.rotationStyle = 'flipped';\nmom.rotationStyle = 'flipped';\ndad.rotationStyle = 'flipped';\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; // 隨機 x 座標\n baby.y = Math.random() * 700 + 100; // 隨機 y 座標\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 updateClock(); //更新計時器\n aniamtion(); //走路動畫\n checkIsGameover(); //確認遊戲是否結束\n }\n \n if (cursor.isDown) {\n info.hidden = true;\n }\n}\n\n\n// 更新叩叮\nfunction updatePlayer () {\n if (player.touched(cursor) == false) {\n player.toward(cursor); //朝向滑鼠\n player.stepForward(6); //向前移動 6 步\n }\n \n if (player.y \u003e 400 \u0026\u0026 player.y \u003c 800 \u0026\u0026 player.x \u003e 1000) {\n total += count;\n count = 0;\n createSound('drop.mp3');\n }\n}\n\n// 更新鵝爸爸與鵝媽媽\nfunction updateParents () {\n if (clock \u003e 120) {\n mom.toward(player); //朝向叩叮\n mom.stepForward(2); //向前移動 2 步\n if (clock % 200 == 0) {\n dad.toward(player); //朝向叩叮 \n }\n dad.stepForward(4); //向前移動 4 步\n }\n}\n\n\n// 更新鵝寶寶\nfunction updateBaby(baby) {\n baby.toward(mom); //朝向鵝媽媽\n baby.stepForward(2); //向前移動 2 步\n baby.toward(player);\n baby.stepForward(-2);\n baby.toward(600, 450);\n baby.stepForward(0.5);\n\n // 鵝寶寶相互遠離\n for (let i = 0; i \u003c 30; i++) {\n baby.toward(babies[i]);\n baby.stepForward(-0.04);\n }\n\n if (baby.touched(player) \u0026\u0026 count \u003c 10) {\n baby.destroy(); //移除角色\n count += 1; //推車上的鵝寶寶數量加 1\n createSound('pick.mp3');\n }\n \n if (clock % 20 \u003e 10) {\n baby.costumeId = 1;\n } else {\n baby.costumeId = 0;\n }\n \n inBox(baby);\n}\n\n// 走路動畫\nfunction aniamtion () {\n if (clock % 20 \u003e 10) {\n player.costumeId = 1;\n mom.costumeId = 1;\n dad.costumeId = 1;\n } else {\n player.costumeId = 0;\n mom.costumeId = 0;\n dad.costumeId = 0;\n }\n if (count \u003e= 3) player.costumeId += 2;\n if (count == 10) player.costumeId += 2;\n}\n\n// 更新計時器\nfunction updateClock () {\n clock++; //紀錄遊戲迴圈的次數\n if (clock \u003e= 3600) {\n //遊戲時間約 60 秒時\n createSprite(\"timesup.png\"); //顯示失敗圖片\n stop(); //暫停遊戲\n createSound('fail.mp3');\n }\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 // 如果 30 隻小鵝都放置完\n if (total == 30) {\n createSprite(\"success.png\"); //顯示獲勝圖片\n stop(); //暫停遊戲\n createSound('success.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); //重複不斷執行遊戲迴圈\n\n","created_at":"2021-03-16T10:32:16.568+08:00","updated_at":"2021-11-25T15:57:37.209+08:00","name":"叩叮捉小鵝(預設版)","language":"javascript","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/235770/b230fa3bcc0fafe3f75ee57f07ce202f.jpg"},"parent_id":235725,"plugin":"Game.set({\n width: 1200, height: 900\n})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":208,"hashid":"36ysmj49y","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4350505,"file_name":"timesup.png","project_id":235770,"asset_id":330423,"created_at":"2021-03-26T17:45:09.041+08:00","updated_at":"2021-03-26T17:45:09.041+08:00"},{"id":4350551,"file_name":"bgm.mp3","project_id":235770,"asset_id":330428,"created_at":"2021-03-26T18:14:38.963+08:00","updated_at":"2021-03-26T18:14:38.963+08:00"},{"id":4350503,"file_name":"p_5.png","project_id":235770,"asset_id":330421,"created_at":"2021-03-26T17:45:08.492+08:00","updated_at":"2021-03-26T17:45:08.492+08:00"},{"id":4350504,"file_name":"success.png","project_id":235770,"asset_id":330422,"created_at":"2021-03-26T17:45:08.494+08:00","updated_at":"2021-03-26T17:45:08.494+08:00"},{"id":4350491,"file_name":"bg.png","project_id":235770,"asset_id":330409,"created_at":"2021-03-26T17:45:04.397+08:00","updated_at":"2021-03-26T17:45:04.397+08:00"},{"id":4350495,"file_name":"info.png","project_id":235770,"asset_id":330413,"created_at":"2021-03-26T17:45:06.155+08:00","updated_at":"2021-03-26T17:45:06.155+08:00"},{"id":4350502,"file_name":"p_4.png","project_id":235770,"asset_id":330420,"created_at":"2021-03-26T17:45:07.748+08:00","updated_at":"2021-03-26T17:45:07.748+08:00"},{"id":4350501,"file_name":"p_3.png","project_id":235770,"asset_id":330419,"created_at":"2021-03-26T17:45:07.746+08:00","updated_at":"2021-03-26T17:45:07.746+08:00"},{"id":4350498,"file_name":"p_0.png","project_id":235770,"asset_id":330416,"created_at":"2021-03-26T17:45:06.679+08:00","updated_at":"2021-03-26T17:45:06.679+08:00"},{"id":4350494,"file_name":"fail.png","project_id":235770,"asset_id":330412,"created_at":"2021-03-26T17:45:05.184+08:00","updated_at":"2021-03-26T17:45:05.184+08:00"},{"id":4350499,"file_name":"p_1.png","project_id":235770,"asset_id":330417,"created_at":"2021-03-26T17:45:07.217+08:00","updated_at":"2021-03-26T17:45:07.217+08:00"},{"id":4350500,"file_name":"p_2.png","project_id":235770,"asset_id":330418,"created_at":"2021-03-26T17:45:07.219+08:00","updated_at":"2021-03-26T17:45:07.219+08:00"},{"id":4350489,"file_name":"baby_0.png","project_id":235770,"asset_id":330407,"created_at":"2021-03-26T17:45:03.635+08:00","updated_at":"2021-03-26T17:45:03.635+08:00"},{"id":4350490,"file_name":"baby_1.png","project_id":235770,"asset_id":330408,"created_at":"2021-03-26T17:45:03.637+08:00","updated_at":"2021-03-26T17:45:03.637+08:00"},{"id":5173026,"file_name":"pick.mp3","project_id":235770,"asset_id":372433,"created_at":"2021-07-01T11:22:31.783+08:00","updated_at":"2021-11-22T15:15:07.214+08:00"},{"id":5173032,"file_name":"mom_0.png","project_id":235770,"asset_id":372437,"created_at":"2021-07-01T11:34:07.473+08:00","updated_at":"2021-07-01T11:34:07.473+08:00"},{"id":5173033,"file_name":"mom_1.png","project_id":235770,"asset_id":372438,"created_at":"2021-07-01T11:34:07.860+08:00","updated_at":"2021-07-01T11:34:07.860+08:00"},{"id":5173025,"file_name":"drop.mp3","project_id":235770,"asset_id":372432,"created_at":"2021-07-01T11:22:30.607+08:00","updated_at":"2021-07-01T11:22:30.607+08:00"},{"id":5173034,"file_name":"dad_1.png","project_id":235770,"asset_id":372439,"created_at":"2021-07-01T11:34:07.862+08:00","updated_at":"2021-07-01T11:34:07.862+08:00"},{"id":5173031,"file_name":"dad_0.png","project_id":235770,"asset_id":372436,"created_at":"2021-07-01T11:34:07.471+08:00","updated_at":"2021-07-01T11:34:07.471+08:00"},{"id":5173024,"file_name":"fail.mp3","project_id":235770,"asset_id":372431,"created_at":"2021-07-01T11:22:29.650+08:00","updated_at":"2021-11-22T15:15:10.880+08:00"},{"id":6565862,"file_name":"win.mp3","project_id":235770,"asset_id":441181,"created_at":"2021-11-22T15:23:00.347+08:00","updated_at":"2021-11-22T15:23:00.347+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦