{"id":313111,"student_id":10,"content":"let bg0 = createSprite('bg_0.png'); //背景1\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('info.png');\n\nlet vx = 10; //財神水平移動的速度\nlet score = 0; //玩家分數\nlet timer = 1800; //遊戲時間\nlet items = []; //存放寶物的陣列\n\nlet bgm = createSound('bgm.mp3');\n\ngod.y = 250;\nplayer.y = 700;\n\ngod.rotationStyle = 'flipped';\nplayer.rotationStyle = 'flipped';\n\n//遊戲主迴圈\nfunction gameloop () {\n \n if (info.hidden) {\n updateTimer(); //更新計時器\n updatePlayer(); //更新玩家\n updateGod(); //更新財神\n updateItems(); //更新寶物\n createItems();\n }\n \n if (key.left || key.right) {\n info.hidden = true;\n }\n\n drawText(Math.floor(timer / 60), 110, 825, 'white', 40); //顯示時間\n drawText(score, 340, 825, 'white', 40); //顯示分數\n\n}\n\n// 更新遊戲計時器\nfunction updateTimer () {\n if (timer \u003e 0) timer--;\n if (timer == 1) {\n createSprite(\"timesup.png\");\n bgm.pause();\n }\n}\n\n// 玩家控制叩叮移動\nfunction updatePlayer () {\n if (timer \u003e 0) {\n if (key.right) {\n player.x += 10;\n player.direction = 90;\n }\n if (key.left) {\n player.x -= 10;\n player.direction = 270;\n }\n \n if (player.x % 100 \u003c 50) {\n player.costumeId = 1;\n } else {\n player.costumeId = 2;\n }\n }\n}\n\n// 財神移動\nfunction updateGod () {\n if (timer \u003e 0) {\n god.x += vx;\n if (god.x \u003e 1100) vx = -10;\n if (god.x \u003c 100) vx = 10;\n if (Math.random() \u003c 0.02) vx *= -1;\n \n if (vx \u003e 0) {\n god.direction = 90;\n } else {\n god.direction = 270;\n }\n \n if (god.x % 100 \u003c 50) {\n god.costumeId = 1;\n } else {\n god.costumeId = 2;\n }\n }\n}\n\n//創造財寶\nfunction createItems () {\n if (timer % 20 == 0 \u0026\u0026 timer \u003e 0) {\n let item = createSprite('item_0.png', 'item_1.png', 'item_2.png', 'item_3.png', 'item_4.png');\n let rand = Math.random();\n item.x = god.x;\n item.y = god.y;\n \n if (rand \u003c 0.3) item.costumeId = 0;\n else if (rand \u003c 0.6) item.costumeId = 1;\n else if (rand \u003c 0.8) item.costumeId = 2;\n else if (rand \u003c 0.9) item.costumeId = 3;\n else item.costumeId = 4;\n \n item.vy = -10;\n items.push(item);\n }\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 += 5;\n \n if (item.touched(player)) {\n item.destroy();\n \n if (item.costumeId == 0) {\n score += 1;\n createSound('e0.mp3');\n } else if (item.costumeId == 1) {\n score += 5;\n createSound('e1.mp3');\n } else if (item.costumeId == 2) {\n score += 30;\n createSound('e2.mp3');\n } else if (item.costumeId == 3) {\n score += 100;\n createSound('e3.mp3');\n } else {\n timer = 0;\n player.costumeId = 3;\n createSound('e4.mp3');\n bgm.pause();\n }\n \n \n }\n if (item.y \u003e 900) {\n item.destroy();\n }\n }\n}\n\nforever(gameloop); // 不斷執行遊戲迴圈\n\n\n","created_at":"2021-11-12T10:24:23.402+08:00","updated_at":"2021-11-12T18:38:53.272+08:00","name":"財神叩叮到(預設版) ","language":"javascript","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/313111/82f66cc447ef502db15785072e713bc3.jpg"},"parent_id":229032,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":160,"hashid":"qmds8pqk8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":6435295,"file_name":"p_3.png","project_id":313111,"asset_id":323947,"created_at":"2021-11-12T10:24:23.408+08:00","updated_at":"2021-11-12T10:24:23.408+08:00"},{"id":6435296,"file_name":"bg_1.png","project_id":313111,"asset_id":323946,"created_at":"2021-11-12T10:24:23.410+08:00","updated_at":"2021-11-12T10:24:23.410+08:00"},{"id":6435297,"file_name":"god_1.png","project_id":313111,"asset_id":323754,"created_at":"2021-11-12T10:24:23.411+08:00","updated_at":"2021-11-12T10:24:23.411+08:00"},{"id":6435298,"file_name":"devil.png","project_id":313111,"asset_id":323753,"created_at":"2021-11-12T10:24:23.411+08:00","updated_at":"2021-11-12T10:24:23.411+08:00"},{"id":6435299,"file_name":"item_2.png","project_id":313111,"asset_id":322158,"created_at":"2021-11-12T10:24:23.412+08:00","updated_at":"2021-11-12T10:24:23.412+08:00"},{"id":6435300,"file_name":"item_0.png","project_id":313111,"asset_id":322153,"created_at":"2021-11-12T10:24:23.414+08:00","updated_at":"2021-11-12T10:24:23.414+08:00"},{"id":6435301,"file_name":"god_2.png","project_id":313111,"asset_id":323752,"created_at":"2021-11-12T10:24:23.414+08:00","updated_at":"2021-11-12T10:24:23.414+08:00"},{"id":6435302,"file_name":"god_0.png","project_id":313111,"asset_id":323750,"created_at":"2021-11-12T10:24:23.415+08:00","updated_at":"2021-11-12T10:24:23.415+08:00"},{"id":6435304,"file_name":"bg_0.png","project_id":313111,"asset_id":323748,"created_at":"2021-11-12T10:24:23.417+08:00","updated_at":"2021-11-12T10:24:23.417+08:00"},{"id":6435308,"file_name":"item_4.png","project_id":313111,"asset_id":322154,"created_at":"2021-11-12T10:24:23.421+08:00","updated_at":"2021-11-12T10:24:23.421+08:00"},{"id":6435309,"file_name":"timesup.png","project_id":313111,"asset_id":322157,"created_at":"2021-11-12T10:24:23.422+08:00","updated_at":"2021-11-12T10:24:23.422+08:00"},{"id":6435310,"file_name":"item_3.png","project_id":313111,"asset_id":322144,"created_at":"2021-11-12T10:24:23.423+08:00","updated_at":"2021-11-12T10:24:23.423+08:00"},{"id":6435311,"file_name":"item_1.png","project_id":313111,"asset_id":322148,"created_at":"2021-11-12T10:24:23.424+08:00","updated_at":"2021-11-12T10:24:23.424+08:00"},{"id":6435312,"file_name":"e2.mp3","project_id":313111,"asset_id":318401,"created_at":"2021-11-12T10:24:23.424+08:00","updated_at":"2021-11-12T10:24:23.424+08:00"},{"id":6435313,"file_name":"e1.mp3","project_id":313111,"asset_id":255906,"created_at":"2021-11-12T10:24:23.426+08:00","updated_at":"2021-11-12T10:24:23.426+08:00"},{"id":6435314,"file_name":"e3.mp3","project_id":313111,"asset_id":318400,"created_at":"2021-11-12T10:24:23.427+08:00","updated_at":"2021-11-12T10:24:23.427+08:00"},{"id":6435315,"file_name":"e4.mp3","project_id":313111,"asset_id":318399,"created_at":"2021-11-12T10:24:23.427+08:00","updated_at":"2021-11-12T10:24:23.427+08:00"},{"id":6435316,"file_name":"bgm.mp3","project_id":313111,"asset_id":318397,"created_at":"2021-11-12T10:24:23.428+08:00","updated_at":"2021-11-12T10:24:23.428+08:00"},{"id":6435306,"file_name":"p_1.png","project_id":313111,"asset_id":323746,"created_at":"2021-11-12T10:24:23.419+08:00","updated_at":"2021-11-12T17:15:07.731+08:00"},{"id":6435307,"file_name":"p_0.png","project_id":313111,"asset_id":323745,"created_at":"2021-11-12T10:24:23.420+08:00","updated_at":"2021-11-12T17:15:11.460+08:00"},{"id":6435305,"file_name":"p_2.png","project_id":313111,"asset_id":323747,"created_at":"2021-11-12T10:24:23.418+08:00","updated_at":"2021-11-12T17:15:20.744+08:00"},{"id":6435303,"file_name":"info.png","project_id":313111,"asset_id":322147,"created_at":"2021-11-12T10:24:23.416+08:00","updated_at":"2021-11-12T17:29:39.345+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦