{"id":476432,"student_id":2589,"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\nlet 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 if (timer % 20 == 0) createItems();\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 {\n item.costumeId = 4; // 10% 機率為炸彈\n devil.moveTo(god);\n }\n item.vy = -10;\n items.push(item);\n}\n\n// 更新財寶的位置\nfunction updateItems () {\n for (let i = 0; i \u003c items.length; i++) {\n let item = items[i];\n item.y += item.vy;\n item.vy += 0.5;\n item.direction += 3;\n if (item.touched(player)) {\n item.hidden = true;\n score += scoreTable[item.costumeId];\n \n if (item.costumeId == 4) {\n gameover();\n timer = 0;\n player.costumeId = 3;\n createSound('bomb.mp3');\n } else {\n createSound('coin.mp3');\n }\n }\n }\n}\n\n// 遊戲結束\nfunction gameover() {\n god.costumeId = 0; //切換面向前造型\n player.costumeId = 0; //切換面向前造型\n bgm.pause(); //停止背景音樂\n}\n\nforever(gameloop); // 不斷執行遊戲迴圈","created_at":"2022-12-20T19:06:39.949+08:00","updated_at":"2023-03-14T10:03:22.304+08:00","name":"財神叩叮到 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"javascript","screenshot":{"url":null},"parent_id":476426,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":69,"hashid":"36ysd44r5","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10843947,"file_name":"bgm.mp3","project_id":476432,"asset_id":591459,"created_at":"2022-12-20T19:06:39.955+08:00","updated_at":"2022-12-20T19:06:39.955+08:00"},{"id":10843948,"file_name":"bomb.mp3","project_id":476432,"asset_id":591460,"created_at":"2022-12-20T19:06:39.956+08:00","updated_at":"2022-12-20T19:06:39.956+08:00"},{"id":10843949,"file_name":"coin.mp3","project_id":476432,"asset_id":591461,"created_at":"2022-12-20T19:06:39.957+08:00","updated_at":"2022-12-20T19:06:39.957+08:00"},{"id":10843950,"file_name":"item_1.png","project_id":476432,"asset_id":591462,"created_at":"2022-12-20T19:06:39.958+08:00","updated_at":"2022-12-20T19:06:39.958+08:00"},{"id":10843951,"file_name":"item_3.png","project_id":476432,"asset_id":591463,"created_at":"2022-12-20T19:06:39.959+08:00","updated_at":"2022-12-20T19:06:39.959+08:00"},{"id":10843952,"file_name":"god_1.png","project_id":476432,"asset_id":591464,"created_at":"2022-12-20T19:06:39.960+08:00","updated_at":"2022-12-20T19:06:39.960+08:00"},{"id":10843953,"file_name":"p_1.png","project_id":476432,"asset_id":591465,"created_at":"2022-12-20T19:06:39.961+08:00","updated_at":"2022-12-20T19:06:39.961+08:00"},{"id":10843954,"file_name":"timesup.png","project_id":476432,"asset_id":591466,"created_at":"2022-12-20T19:06:39.962+08:00","updated_at":"2022-12-20T19:06:39.962+08:00"},{"id":10843955,"file_name":"item_4.png","project_id":476432,"asset_id":591467,"created_at":"2022-12-20T19:06:39.963+08:00","updated_at":"2022-12-20T19:06:39.963+08:00"},{"id":10843956,"file_name":"item_0.png","project_id":476432,"asset_id":591468,"created_at":"2022-12-20T19:06:39.964+08:00","updated_at":"2022-12-20T19:06:39.964+08:00"},{"id":10843957,"file_name":"item_2.png","project_id":476432,"asset_id":591469,"created_at":"2022-12-20T19:06:39.965+08:00","updated_at":"2022-12-20T19:06:39.965+08:00"},{"id":10843958,"file_name":"god_0.png","project_id":476432,"asset_id":591470,"created_at":"2022-12-20T19:06:39.966+08:00","updated_at":"2022-12-20T19:06:39.966+08:00"},{"id":10843959,"file_name":"god_2.png","project_id":476432,"asset_id":591471,"created_at":"2022-12-20T19:06:39.967+08:00","updated_at":"2022-12-20T19:06:39.967+08:00"},{"id":10843960,"file_name":"devil.png","project_id":476432,"asset_id":591472,"created_at":"2022-12-20T19:06:39.968+08:00","updated_at":"2022-12-20T19:06:39.968+08:00"},{"id":10843961,"file_name":"infoo.png","project_id":476432,"asset_id":591473,"created_at":"2022-12-20T19:06:39.968+08:00","updated_at":"2022-12-20T19:06:39.968+08:00"},{"id":10843962,"file_name":"bg_0.png","project_id":476432,"asset_id":591474,"created_at":"2022-12-20T19:06:39.969+08:00","updated_at":"2022-12-20T19:06:39.969+08:00"},{"id":10843963,"file_name":"bg_1.png","project_id":476432,"asset_id":591475,"created_at":"2022-12-20T19:06:39.970+08:00","updated_at":"2022-12-20T19:06:39.970+08:00"},{"id":10843964,"file_name":"p_3.png","project_id":476432,"asset_id":591476,"created_at":"2022-12-20T19:06:39.971+08:00","updated_at":"2022-12-20T19:06:39.971+08:00"},{"id":10843965,"file_name":"p_2.png","project_id":476432,"asset_id":591477,"created_at":"2022-12-20T19:06:39.972+08:00","updated_at":"2022-12-20T19:06:39.972+08:00"},{"id":10843966,"file_name":"p_0.png","project_id":476432,"asset_id":591478,"created_at":"2022-12-20T19:06:39.973+08:00","updated_at":"2022-12-20T19:06:39.973+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦