{"id":481921,"student_id":10,"content":"setBackdrop('bg.png'); //設定背景圖\nlet boat = createSprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png'); //火鍋船\nlet hook = createSprite('h_0.png', 'h_1.png', 'h_2.png', 'h_3.png', 'h_4.png', 'h_5.png', 'h_6.png', 'h_7.png', 'h_8.png'); //魚鉤\nlet board = createSprite('board.png'); //能量條框\nlet info = createSprite('info.png'); //遊戲說明\nlet vx = 0; //魚鉤的水平移動速度\nlet vy = 0; //魚鉤的垂直移動速度\nlet score = 0; //玩家得分\nvar power = 1200; //能量條\n\nlet fish = []; //存放海中角色的陣列\nlet scoreTable = [100, 100, 200, 300, 400, -200, -200, -200]; //角色分數對應表\nlet speedTable = [2, 2, 4, 6, 8, 3, 2, 3]; //角色速度對應表\n\nboat.rotationStyle = 'flipped';\nboat.moveTo(300, 300);\nhook.moveTo(400, 600);\nhook.costumeId = 8; // 設定為空鉤造型\ninfo.layer = 1;\ninfo.hidden = true; //直接隱藏遊戲說明\n\n// 初始化海中的角色\nfor (let i = 0; i \u003c 15; i++) {\n let f = createSprite('f_0.png', 'f_1.png', 'f_2.png', 'f_3.png', 'f_4.png', 'f_5.png', 'f_6.png', 'f_7.png'); //創造海中角色\n f.x = Math.random() * 1800 - 300; //隨機水平位置\n f.y = Math.random() * 500 + 400; //隨機垂直位置\n f.costumeId = Math.floor(Math.random()*8);\n f.rotationStyle = 'flipped'; //設定水平翻轉屬性\n if (Math.random() \u003e 0.5) f.direction += 180; //隨機向左或向右\n fish.push(f);\n}\n\n// 遊戲主迴圈\nfunction gameloop () {\n if (info.hidden) { // 如果遊戲說明隱藏\n updateHook(); //更新魚鉤\n updateBoat(); //移動火鍋船\n updatePower(); //更新能量條\n hookTouchBoat(); //偵測魚鉤與船的碰撞\n for (let i = 0; i \u003c fish.length; i++) {\n updateFish(fish[i]);\n } \n }\n if (key.space) info.hidden = true; //按下空白按鍵開始遊戲\n}\n\n// 更新移動魚鉤\nfunction updateHook () {\n hook.x += vx; //改變水平位置\n hook.y += vy; //改變垂直位置\n\n if (hook.x \u003c 0 \u0026\u0026 vx \u003c 0) vx = -vx; //碰到左邊邊界反彈\n if (hook.x \u003e 1200 \u0026\u0026 vx \u003e 0) vx = -vx; //碰到右邊邊界反彈\n if (hook.y \u003c 0 \u0026\u0026 vy \u003c 0) vy = -vy; //碰到上面邊界反彈\n if (hook.y \u003e 900 \u0026\u0026 vy \u003e 0) vy = -vy; //碰到下面邊界反彈\n\n if (key.right) vx += 0.2; //按下右鍵向右加速\n if (key.left) vx -= 0.2; //按下左鍵向左加速\n if (key.up \u0026\u0026 hook.y \u003e 400) vy = -10; //按下上鍵且沒有超出海面\n if (key.down) vy += 0.2; //按下下鍵向下加速\n if (hook.y \u003c 300) vy += 0.2; \n \n vy += hook.y \u003c 300 ? 0.1 : -0.02; //水面之上就下墜水面之下就上飄\n vx += boat.x \u003e hook.x ? 0.02: -0.02; //魚鉤飄向船的位置\n \n vx *= 0.99; //速度衰減\n vy *= 0.99; //速度衰減\n}\n\n//更新海中角色\nfunction updateFish (f) {\n \n let speed = speedTable[f.costumeId];\n f.stepForward(speed); //向前移動\n \n // 碰到邊界轉向\n if (f.x \u003c -600 || f.x \u003e 1800) {\n f.direction += 180; //轉向\n f.hidden = false; //將隱藏的角色重新顯示\n f.y = Math.random() * 500 + 400; //隨機垂直位置\n f.stepForward(Math.random() * 150); //向前移動隨機距離\n f.costumeId = Math.floor(Math.random()*8); //隨機切換圖片造型\n }\n \n if (hook.touched(f) \u0026\u0026 hook.costumeId == 8 \u0026\u0026 vy \u003c -4) {\n hook.costumeId = f.costumeId;\n f.hidden = true;\n }\n\n}\n\n// 偵測魚鉤是否碰撞到船\nfunction hookTouchBoat () {\n if (hook.touched(boat) \u0026\u0026 hook.costumeId != 8 \u0026\u0026 vy \u003e 0) {\n score += scoreTable[hook.costumeId];\n power += scoreTable[hook.costumeId];\n hook.costumeId = 8;\n }\n}\n\n// 更新能量條\nfunction updatePower () {\n power -= 0.75; //能量不斷減少\n drawText('score: ' + score, 20, 60, 'black', 40); //顯示分數\n pen.fillColor = 'red'; //畫筆設定為紅色\n pen.drawRect(0, 0, power, 50); //繪製紅色能量條\n if (power \u003e 1200) power = 1200; //限制能量條上限 1200\n if (power \u003c 0) boat.costumeId = 2; // 如果能量條用完火鍋蓋上蓋子\n}\n\n//更新火鍋船\nfunction updateBoat () {\n \n // 如果火鍋蓋住蓋子\n if (boat.costumeId == 2) {\n boat.y += 3; //向下沈\n hook.hidden = true; //隱藏鉤子\n } else {\n boat.stepForward(2); //向前移動\n boat.costumeId = Math.floor((boat.x + 2) / 50) % 2; //來回切換造型\n pen.color = 'black';\n pen.drawLine(boat.x, boat.y - 150, hook.x, hook.y);\n }\n \n // 船碰到左右邊界就反轉方向\n if (boat.x \u003c 100 || boat.x \u003e 1100) boat.direction += 180;\n \n // 如果船沈到底,根據分數顯示完成度\n if (boat.y \u003e 1300) {\n if (score \u003c 0) createSprite('r_0.png');\n else if (score \u003c 1000) createSprite('r_1.png');\n else if (score \u003c 2000) createSprite('r_2.png');\n else if (score \u003c 3000) createSprite('r_3.png');\n else if (score \u003c 4000) createSprite('r_4.png');\n else createSprite('r_5.png');\n stop(); //停止遊戲\n }\n}\n\nforever(gameloop) //不斷執行遊戲迴圈\n\n","created_at":"2023-01-10T10:18:14.994+08:00","updated_at":"2024-01-15T23:38:42.819+08:00","name":"天才小釣手(延伸挑戰版) ","language":"javascript","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/481921/c2001a95d55bf6b0efeaab9f89c89a65.jpg"},"parent_id":481914,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":103,"hashid":"yeysqpzwk","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":10963969,"file_name":"f_2.png","project_id":481921,"asset_id":595486,"created_at":"2023-01-10T10:18:15.005+08:00","updated_at":"2023-01-10T10:18:15.005+08:00"},{"id":10963970,"file_name":"f_3.png","project_id":481921,"asset_id":595487,"created_at":"2023-01-10T10:18:15.007+08:00","updated_at":"2023-01-10T10:18:15.007+08:00"},{"id":10963971,"file_name":"f_0.png","project_id":481921,"asset_id":595488,"created_at":"2023-01-10T10:18:15.008+08:00","updated_at":"2023-01-10T10:18:15.008+08:00"},{"id":10963972,"file_name":"f_1.png","project_id":481921,"asset_id":595489,"created_at":"2023-01-10T10:18:15.010+08:00","updated_at":"2023-01-10T10:18:15.010+08:00"},{"id":10963973,"file_name":"f_6.png","project_id":481921,"asset_id":595490,"created_at":"2023-01-10T10:18:15.011+08:00","updated_at":"2023-01-10T10:18:15.011+08:00"},{"id":10963974,"file_name":"f_7.png","project_id":481921,"asset_id":595491,"created_at":"2023-01-10T10:18:15.012+08:00","updated_at":"2023-01-10T10:18:15.012+08:00"},{"id":10963975,"file_name":"f_4.png","project_id":481921,"asset_id":595492,"created_at":"2023-01-10T10:18:15.014+08:00","updated_at":"2023-01-10T10:18:15.014+08:00"},{"id":10963976,"file_name":"f_5.png","project_id":481921,"asset_id":595493,"created_at":"2023-01-10T10:18:15.015+08:00","updated_at":"2023-01-10T10:18:15.015+08:00"},{"id":10963977,"file_name":"board.png","project_id":481921,"asset_id":595494,"created_at":"2023-01-10T10:18:15.016+08:00","updated_at":"2023-01-10T10:18:15.016+08:00"},{"id":10963978,"file_name":"r_1.png","project_id":481921,"asset_id":595495,"created_at":"2023-01-10T10:18:15.017+08:00","updated_at":"2023-01-10T10:18:15.017+08:00"},{"id":10963979,"file_name":"r_0.png","project_id":481921,"asset_id":595496,"created_at":"2023-01-10T10:18:15.018+08:00","updated_at":"2023-01-10T10:18:15.018+08:00"},{"id":10963980,"file_name":"p_1.png","project_id":481921,"asset_id":595497,"created_at":"2023-01-10T10:18:15.019+08:00","updated_at":"2023-01-10T10:18:15.019+08:00"},{"id":10963981,"file_name":"bg.png","project_id":481921,"asset_id":595498,"created_at":"2023-01-10T10:18:15.020+08:00","updated_at":"2023-01-10T10:18:15.020+08:00"},{"id":10963982,"file_name":"info.png","project_id":481921,"asset_id":595499,"created_at":"2023-01-10T10:18:15.021+08:00","updated_at":"2023-01-10T10:18:15.021+08:00"},{"id":10963983,"file_name":"r_2.png","project_id":481921,"asset_id":595500,"created_at":"2023-01-10T10:18:15.022+08:00","updated_at":"2023-01-10T10:18:15.022+08:00"},{"id":10963984,"file_name":"r_3.png","project_id":481921,"asset_id":595501,"created_at":"2023-01-10T10:18:15.023+08:00","updated_at":"2023-01-10T10:18:15.023+08:00"},{"id":10963985,"file_name":"r_4.png","project_id":481921,"asset_id":595502,"created_at":"2023-01-10T10:18:15.024+08:00","updated_at":"2023-01-10T10:18:15.024+08:00"},{"id":10963986,"file_name":"r_5.png","project_id":481921,"asset_id":595503,"created_at":"2023-01-10T10:18:15.025+08:00","updated_at":"2023-01-10T10:18:15.025+08:00"},{"id":10963987,"file_name":"p_3.png","project_id":481921,"asset_id":595504,"created_at":"2023-01-10T10:18:15.026+08:00","updated_at":"2023-01-10T10:18:15.026+08:00"},{"id":10963988,"file_name":"h_3.png","project_id":481921,"asset_id":595505,"created_at":"2023-01-10T10:18:15.027+08:00","updated_at":"2023-01-10T10:18:15.027+08:00"},{"id":10963989,"file_name":"h_4.png","project_id":481921,"asset_id":595506,"created_at":"2023-01-10T10:18:15.028+08:00","updated_at":"2023-01-10T10:18:15.028+08:00"},{"id":10963990,"file_name":"h_5.png","project_id":481921,"asset_id":595507,"created_at":"2023-01-10T10:18:15.029+08:00","updated_at":"2023-01-10T10:18:15.029+08:00"},{"id":10963991,"file_name":"h_6.png","project_id":481921,"asset_id":595508,"created_at":"2023-01-10T10:18:15.030+08:00","updated_at":"2023-01-10T10:18:15.030+08:00"},{"id":10963992,"file_name":"h_7.png","project_id":481921,"asset_id":595509,"created_at":"2023-01-10T10:18:15.031+08:00","updated_at":"2023-01-10T10:18:15.031+08:00"},{"id":10963993,"file_name":"p_0.png","project_id":481921,"asset_id":595510,"created_at":"2023-01-10T10:18:15.032+08:00","updated_at":"2023-01-10T10:18:15.032+08:00"},{"id":10963994,"file_name":"h_8.png","project_id":481921,"asset_id":595511,"created_at":"2023-01-10T10:18:15.033+08:00","updated_at":"2023-01-10T10:18:15.033+08:00"},{"id":10963995,"file_name":"h_0.png","project_id":481921,"asset_id":595512,"created_at":"2023-01-10T10:18:15.034+08:00","updated_at":"2023-01-10T10:18:15.034+08:00"},{"id":10963996,"file_name":"h_1.png","project_id":481921,"asset_id":595513,"created_at":"2023-01-10T10:18:15.035+08:00","updated_at":"2023-01-10T10:18:15.035+08:00"},{"id":10963997,"file_name":"h_2.png","project_id":481921,"asset_id":595514,"created_at":"2023-01-10T10:18:15.036+08:00","updated_at":"2023-01-10T10:18:15.036+08:00"},{"id":10963998,"file_name":"p_2.png","project_id":481921,"asset_id":595515,"created_at":"2023-01-10T10:18:15.037+08:00","updated_at":"2023-01-10T10:18:15.037+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦