{"id":531080,"student_id":1444,"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 }\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 item.vy = -10;\n items.push(item);\n}\n\n// 更新財寶的位置\nfunction updateItems () {\n for (var 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 if(item.costumeId == 4){\n gameover();\n timer = 0;\n player.costumeId = 3;\n }\n }\n}\n}\n\n// 遊戲結束\nfunction gameover() {\ncreateSprite('timesup.png'); //創造時間到圖片\ngod.costumeId = 0; //切換面向前造型\nplayer.costumeId = 0; //切換面向前造型\n// bgm.pause(); //停止背景音樂\n}\n\nforever(gameloop); // 不斷執行遊戲迴圈","created_at":"2023-05-08T18:59:23.947+08:00","updated_at":"2023-05-08T19:24:12.160+08:00","name":"財神叩叮到(預設版) 副本","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/531080/8c395614a1b2a4ad02818e61ad954c51.jpg"},"parent_id":476423,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":43,"hashid":"rdvs4km3j","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":12109626,"file_name":"bomb.mp3","project_id":531080,"asset_id":591440,"created_at":"2023-05-08T18:59:23.954+08:00","updated_at":"2023-05-08T18:59:23.954+08:00"},{"id":12109627,"file_name":"coin.mp3","project_id":531080,"asset_id":591441,"created_at":"2023-05-08T18:59:23.956+08:00","updated_at":"2023-05-08T18:59:23.956+08:00"},{"id":12109628,"file_name":"item_1.png","project_id":531080,"asset_id":591442,"created_at":"2023-05-08T18:59:23.958+08:00","updated_at":"2023-05-08T18:59:23.958+08:00"},{"id":12109629,"file_name":"item_3.png","project_id":531080,"asset_id":591443,"created_at":"2023-05-08T18:59:23.960+08:00","updated_at":"2023-05-08T18:59:23.960+08:00"},{"id":12109630,"file_name":"god_1.png","project_id":531080,"asset_id":591444,"created_at":"2023-05-08T18:59:23.963+08:00","updated_at":"2023-05-08T18:59:23.963+08:00"},{"id":12109631,"file_name":"p_1.png","project_id":531080,"asset_id":591445,"created_at":"2023-05-08T18:59:23.964+08:00","updated_at":"2023-05-08T18:59:23.964+08:00"},{"id":12109632,"file_name":"timesup.png","project_id":531080,"asset_id":591446,"created_at":"2023-05-08T18:59:23.966+08:00","updated_at":"2023-05-08T18:59:23.966+08:00"},{"id":12109633,"file_name":"item_4.png","project_id":531080,"asset_id":591447,"created_at":"2023-05-08T18:59:23.967+08:00","updated_at":"2023-05-08T18:59:23.967+08:00"},{"id":12109634,"file_name":"item_0.png","project_id":531080,"asset_id":591448,"created_at":"2023-05-08T18:59:23.969+08:00","updated_at":"2023-05-08T18:59:23.969+08:00"},{"id":12109635,"file_name":"item_2.png","project_id":531080,"asset_id":591449,"created_at":"2023-05-08T18:59:23.971+08:00","updated_at":"2023-05-08T18:59:23.971+08:00"},{"id":12109636,"file_name":"god_0.png","project_id":531080,"asset_id":591450,"created_at":"2023-05-08T18:59:23.973+08:00","updated_at":"2023-05-08T18:59:23.973+08:00"},{"id":12109637,"file_name":"god_2.png","project_id":531080,"asset_id":591451,"created_at":"2023-05-08T18:59:23.974+08:00","updated_at":"2023-05-08T18:59:23.974+08:00"},{"id":12109638,"file_name":"devil.png","project_id":531080,"asset_id":591452,"created_at":"2023-05-08T18:59:23.976+08:00","updated_at":"2023-05-08T18:59:23.976+08:00"},{"id":12109639,"file_name":"infoo.png","project_id":531080,"asset_id":591453,"created_at":"2023-05-08T18:59:23.979+08:00","updated_at":"2023-05-08T18:59:23.979+08:00"},{"id":12109640,"file_name":"bg_0.png","project_id":531080,"asset_id":591454,"created_at":"2023-05-08T18:59:23.980+08:00","updated_at":"2023-05-08T18:59:23.980+08:00"},{"id":12109641,"file_name":"bg_1.png","project_id":531080,"asset_id":591455,"created_at":"2023-05-08T18:59:23.982+08:00","updated_at":"2023-05-08T18:59:23.982+08:00"},{"id":12109642,"file_name":"p_3.png","project_id":531080,"asset_id":591456,"created_at":"2023-05-08T18:59:23.984+08:00","updated_at":"2023-05-08T18:59:23.984+08:00"},{"id":12109643,"file_name":"p_2.png","project_id":531080,"asset_id":591457,"created_at":"2023-05-08T18:59:23.986+08:00","updated_at":"2023-05-08T18:59:23.986+08:00"},{"id":12109644,"file_name":"p_0.png","project_id":531080,"asset_id":591458,"created_at":"2023-05-08T18:59:23.989+08:00","updated_at":"2023-05-08T18:59:23.989+08:00"},{"id":12109645,"file_name":"bgm.mp3","project_id":531080,"asset_id":604465,"created_at":"2023-05-08T18:59:23.990+08:00","updated_at":"2023-05-08T18:59:23.990+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦