{"id":480667,"student_id":10,"content":"let bg0 = createSprite('bg_0.png'); //背景1\nlet devil = createSprite('devil.png'); //惡魔\nlet bg1 = createSprite('bg_1.png'); //背景2\nlet god = createSprite('god_0.png', 'god_1.png', 'god_2.png'); //財神\nlet player = createSprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png'); //玩家\nlet info = createSprite('infoo.png'); //遊戲說明\n\nlet godVX = 10; //財神水平速度\nlet playerVX = 10; //玩家水平速度\nlet score = 0; //玩家分數\nlet timer = 3600; //遊戲時間\nlet items = []; //存放寶物角色\nlet scoreTable = [1, 5, 10, 30, 0]; //分數對照表\n\ngod.y = 210; //財神初始化在場景上方\nplayer.y = 700; //叩叮初始化在場景下方\n\nplayer.rotationStyle = 'flipped'; //玩家圖片水平翻轉\ngod.rotationStyle = 'flipped'; //財神圖片水平翻轉\n\n// let bgm = createSound('bgm.mp3'); //背景音樂\n\n//遊戲迴圈\nfunction gameloop () {\n // 遊戲說明隱藏而且遊戲時間還沒到\n if (info.hidden \u0026\u0026 timer \u003e 0) {\n timer--; //剩餘時間減少 1\n updatePlayer(); //更新玩家\n updateGod(); //更新財神\n animation(); //走路動畫\n if (timer == 0) gameover(); //結束遊戲\n devil.y += 1;\n }\n updateItems(); //更新物件\n drawTexts(); //顯示時間分數\n\n // 按下右鍵或左鍵\n if (key.right || key.left) {\n info.hidden = true; //隱藏說明圖\n }\n}\n\n// 玩家移動\nfunction updatePlayer () {\n player.x += playerVX; // 根據 playerVX 改變水平位置\n if (key.right) playerVX = 10; //按下右鍵速度向右\n if (key.left) playerVX = -10; //按下左鍵速度向左\n}\n\n// 財神移動\nfunction updateGod () {\n god.x += godVX; // 根據 godVX 改變水平位置\n if (god.x \u003e 1100) godVX = -10; //超過右邊就速度向左\n if (god.x \u003c 100) godVX = 10; //超過右邊就速度向右\n if (Math.random() \u003c 0.02) godVX = -godVX; //隨機轉向\n}\n\n// 走路動畫\nfunction animation() {\n player.costumeId = player.x % 100 \u003c 50 ? 1: 2; //玩家走路動畫\n god.costumeId = god.x % 100 \u003c 50 ? 1: 2; //財神走路動畫\n god.direction = godVX \u003e 0 ? 90: 270; //財神圖片水平翻轉\n player.direction = playerVX \u003e 0 ? 90: 270; //玩家圖片水平翻轉\n}\n\n// 顯示文字\nfunction drawTexts() {\n drawText(Math.floor(timer / 60), 110, 825, 'white', 40); //顯示剩餘時間\n drawText(score, 340, 825, 'white', 40); //顯示分數\n}\n\n//創造財寶\nfunction createItems () {\n let item = createSprite('item_0.png', 'item_1.png', 'item_2.png', 'item_3.png', 'item_4.png');\n item.moveTo(god); //將寶物移動到財神爺位置\n item.costumeId = Math.floor(Math.random() * 5); //隨機切換造型\n let rand = Math.random(); //產生一個隨機數\n if (rand \u003c 0.3) item.costumeId = 0; // 30% 機率為金幣\n else if (rand \u003c 0.6) item.costumeId = 1; // 30% 機率為寶石\n else if (rand \u003c 0.8) item.costumeId = 2; // 20% 機率為錢袋\n else if (rand \u003c 0.9) item.costumeId = 3; // 10% 機率為寶箱\n else item.costumeId = 4; // 10% 機率為炸彈\n}\n\n// 更新財寶的位置\nfunction updateItems () {\n\n}\n\n// 遊戲結束\nfunction gameover() {c\n god.costumeId = 0; //切換面向前造型\n player.costumeId = 0; //切換面向前造型\n bgm.pause(); //停止背景音樂\n}\n\nforever(gameloop); // 不斷執行遊戲迴圈","created_at":"2023-01-05T18:16:13.678+08:00","updated_at":"2023-01-05T18:16:13.678+08:00","name":"財神叩叮到(預設版) 副本","language":"javascript","screenshot":{"url":null},"parent_id":476423,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":104,"hashid":"yeysqm688","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10935444,"file_name":"bgm.mp3","project_id":480667,"asset_id":591439,"created_at":"2023-01-05T18:16:13.684+08:00","updated_at":"2023-01-05T18:16:13.684+08:00"},{"id":10935445,"file_name":"bomb.mp3","project_id":480667,"asset_id":591440,"created_at":"2023-01-05T18:16:13.686+08:00","updated_at":"2023-01-05T18:16:13.686+08:00"},{"id":10935446,"file_name":"coin.mp3","project_id":480667,"asset_id":591441,"created_at":"2023-01-05T18:16:13.687+08:00","updated_at":"2023-01-05T18:16:13.687+08:00"},{"id":10935447,"file_name":"item_1.png","project_id":480667,"asset_id":591442,"created_at":"2023-01-05T18:16:13.689+08:00","updated_at":"2023-01-05T18:16:13.689+08:00"},{"id":10935448,"file_name":"item_3.png","project_id":480667,"asset_id":591443,"created_at":"2023-01-05T18:16:13.690+08:00","updated_at":"2023-01-05T18:16:13.690+08:00"},{"id":10935449,"file_name":"god_1.png","project_id":480667,"asset_id":591444,"created_at":"2023-01-05T18:16:13.691+08:00","updated_at":"2023-01-05T18:16:13.691+08:00"},{"id":10935450,"file_name":"p_1.png","project_id":480667,"asset_id":591445,"created_at":"2023-01-05T18:16:13.692+08:00","updated_at":"2023-01-05T18:16:13.692+08:00"},{"id":10935451,"file_name":"timesup.png","project_id":480667,"asset_id":591446,"created_at":"2023-01-05T18:16:13.693+08:00","updated_at":"2023-01-05T18:16:13.693+08:00"},{"id":10935452,"file_name":"item_4.png","project_id":480667,"asset_id":591447,"created_at":"2023-01-05T18:16:13.695+08:00","updated_at":"2023-01-05T18:16:13.695+08:00"},{"id":10935453,"file_name":"item_0.png","project_id":480667,"asset_id":591448,"created_at":"2023-01-05T18:16:13.696+08:00","updated_at":"2023-01-05T18:16:13.696+08:00"},{"id":10935454,"file_name":"item_2.png","project_id":480667,"asset_id":591449,"created_at":"2023-01-05T18:16:13.698+08:00","updated_at":"2023-01-05T18:16:13.698+08:00"},{"id":10935455,"file_name":"god_0.png","project_id":480667,"asset_id":591450,"created_at":"2023-01-05T18:16:13.699+08:00","updated_at":"2023-01-05T18:16:13.699+08:00"},{"id":10935456,"file_name":"god_2.png","project_id":480667,"asset_id":591451,"created_at":"2023-01-05T18:16:13.701+08:00","updated_at":"2023-01-05T18:16:13.701+08:00"},{"id":10935457,"file_name":"devil.png","project_id":480667,"asset_id":591452,"created_at":"2023-01-05T18:16:13.702+08:00","updated_at":"2023-01-05T18:16:13.702+08:00"},{"id":10935458,"file_name":"infoo.png","project_id":480667,"asset_id":591453,"created_at":"2023-01-05T18:16:13.704+08:00","updated_at":"2023-01-05T18:16:13.704+08:00"},{"id":10935459,"file_name":"bg_0.png","project_id":480667,"asset_id":591454,"created_at":"2023-01-05T18:16:13.705+08:00","updated_at":"2023-01-05T18:16:13.705+08:00"},{"id":10935460,"file_name":"bg_1.png","project_id":480667,"asset_id":591455,"created_at":"2023-01-05T18:16:13.706+08:00","updated_at":"2023-01-05T18:16:13.706+08:00"},{"id":10935461,"file_name":"p_3.png","project_id":480667,"asset_id":591456,"created_at":"2023-01-05T18:16:13.708+08:00","updated_at":"2023-01-05T18:16:13.708+08:00"},{"id":10935462,"file_name":"p_2.png","project_id":480667,"asset_id":591457,"created_at":"2023-01-05T18:16:13.709+08:00","updated_at":"2023-01-05T18:16:13.709+08:00"},{"id":10935463,"file_name":"p_0.png","project_id":480667,"asset_id":591458,"created_at":"2023-01-05T18:16:13.710+08:00","updated_at":"2023-01-05T18:16:13.710+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦