{"id":623749,"student_id":3760,"content":"// 【學習】建立背景音樂\n// 建立一個音訊角色,其中音訊檔為 bgm.mp3\n\n// 【學習】初始化背景\n// 建立一個名為 sky 的角色,其造型為 sky.jpg\nsky.x = 600;\nsky.y = 2400;\n\n// 【學習】初始化叩叮角色\n// 建立一個名為 koding 的角色,其造型為 koding.png\nkoding.x = 600;\nkoding.y = 100;\n\n// 【學習】初始化三種障礙物角色\n// 【學習】鳥角色\n// 建立一個名為 bird 的角色,其造型為 birdRight.png 以及 birdLeft.png\n// 【學習】設定鳥角色的造型至面向右邊的造型\n// 將鳥角色的造型至面向右邊的造型\nbird.x = 1500;\n\n// 設定 isBirdMoving 變數,用來觀察鳥角色現在是否正在移動\nlet isBirdMoving = false\n// 設定 birdCostume 變數,紀錄目前鳥角色的造型編號\nlet birdCostume = 0;\n\n// 【學習】老鷹角色\n// 建立一個名為 eagle 的角色,其造型為 eagle.png\neagle.x = -300;\n\n// 飛機角色\nlet plane = createSprite(\"plane.png\");\nplane.x = -300;\n\n// 初始化小比例尺角色\n// 【學習】小比例尺角色\n// 建立一個名為 map 的角色,其造型為 map.svg\nmap.x = 1100\nmap.y = 700\n\n// 小比例尺指標角色\nlet pointer = createSprite(\"pointer.svg\");\npointer.x = 1095;\npointer.y = 600;\n\n\n// 偵測叩叮是否碰撞到其他障礙物,若碰撞到則 gameover\nkoding.on('touch', [bird, eagle, plane], gameover);\n\n\n// 移動小比例尺指標\nfunction movePointer() {\n if (pointer.y \u003c 800) {\n pointer.y += 0.07;\n } else {\n pointer.hidden = true;\n map.hidden = true;\n }\n}\n\n// 移動叩叮上下左右\nfunction moveKoding() {\n koding.direction = 90;\n if (key.right \u0026\u0026 koding.x \u003c 1200) {\n koding.x += 5;\n koding.direction = 80;\n }\n if (key.left \u0026\u0026 koding.x \u003e 0) {\n koding.x -= 5;\n koding.direction = 100;\n }\n if (key.up \u0026\u0026 koding.y \u003e 0) {\n koding.y -= 5;\n }\n if (key.down \u0026\u0026 koding.y \u003c 900) {\n koding.y += 5;\n }\n}\n\n// 上移背景(相當於叩叮往下掉)\nfunction fallDown() {\n if (sky.y \u003e -1500) {\n sky.y -= 1.5;\n }\n}\n\n// 選擇鳥角色造型\nfunction setBirdCostume() {\n if (isBirdMoving) {\n return birdCostume;\n }\n birdCostume = Math.floor(Math.random()*2);\n return birdCostume;\n}\n\n// 移動鳥角色\nfunction moveBird() {\n if (birdCostume === 0) {\n // 鳥角色由左向右移動\n // 【學習】設定鳥角色的造型至面向右邊的造型\n // 將鳥角色的造型至面向右邊的造型\n bird.x += 2;\n isBirdMoving = true;\n if (bird.x \u003e 1200 \u0026\u0026 sky.y \u003e -1000) {\n // -500~-200\n bird.x = (-500) + Math.random()*300;\n // 200~700\n bird.y = 200 + Math.random()*500;\n isBirdMoving = false;\n }\n } else {\n // 鳥角色由右向左移動\n // 【學習】設定鳥角色的造型至面向左邊的造型\n // 將鳥角色的造型至面向左邊的造型\n bird.x -= 2;\n isBirdMoving = true;\n if (bird.x \u003c -100 \u0026\u0026 sky.y \u003e -1000) {\n // 1200~1500\n bird.x = 1200 + Math.random()*300;\n // 200~700\n bird.y = 200 + Math.random()*500;\n isBirdMoving = false;\n }\n }\n}\n\n// 移動老鷹角色\nfunction moveEagle() {\n eagle.x -= 4;\n if (eagle.x \u003c 0 \u0026\u0026 sky.y \u003e -1000) {\n //1400~1700\n eagle.x = 1400 + Math.random()*300;\n //200~700\n eagle.y = 200 + Math.random()*500;\n }\n}\n\n// 移動飛機角色\nfunction movePlane() {\n plane.x -= 6;\n plane.y -= 2;\n if (plane.x \u003c 0 \u0026\u0026 sky.y \u003e -1000) {\n //1400~1700\n plane.x = 1400 + Math.random()*300;\n //200~700\n plane.y = 300 + Math.random()*500;\n }\n}\n\n// 讓叩叮安全降落\nfunction landing() {\n if (sky.y \u003c= -1500) {\n if (koding.y \u003c 700) {\n koding.y += 1;\n } else {\n win();\n }\n }\n}\n\n// 遊戲結束 - 勝利\nfunction win() {\n // 停下所有遊戲動作\n stop();\n // 【學習】建立 youwin 角色\n // 建立一個名為 youwin 的角色,其造型為 youwin.png\n}\n\n// 遊戲結束 - 失敗\nfunction gameover() {\n // 停下所有遊戲動作\n stop();\n // 【學習】建立擊毀音效\n // 建立一個音訊角色,其中音訊檔為 crash.mp3\n \n // 【學習】建立 explode 角色\n // 建立一個名為 explode 的角色,其造型為 explode.png\n explode.x = koding.x;\n explode.y = koding.y;\n \n // 【學習】建立 gameover 角色\n let gameover = createSprite(\"gameover.png\");\n}\n\n// 不停執行的迴圈函式\nforever(function() {\n movePointer();\n moveKoding();\n fallDown();\n setBirdCostume();\n moveBird();\n moveEagle();\n movePlane();\n landing();\n});\n","created_at":"2023-10-18T18:31:29.233+08:00","updated_at":"2023-10-31T16:42:08.644+08:00","name":"JS 高空飛行傘_學生","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/623749/d7f72eb85f77b49e3fb4f79f33aa33bb.jpg"},"parent_id":616103,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":38,"hashid":"qmdswvd2d","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":14020576,"file_name":"Playdate.mp3","project_id":623749,"asset_id":248784,"created_at":"2023-10-18T18:31:29.243+08:00","updated_at":"2023-10-18T18:31:29.243+08:00"},{"id":14020577,"file_name":"crash.mp3","project_id":623749,"asset_id":248773,"created_at":"2023-10-18T18:31:29.244+08:00","updated_at":"2023-10-18T18:31:29.244+08:00"},{"id":14020578,"file_name":"explode.png","project_id":623749,"asset_id":251476,"created_at":"2023-10-18T18:31:29.245+08:00","updated_at":"2023-10-18T18:31:29.245+08:00"},{"id":14020579,"file_name":"plane.png","project_id":623749,"asset_id":251478,"created_at":"2023-10-18T18:31:29.246+08:00","updated_at":"2023-10-18T18:31:29.246+08:00"},{"id":14020580,"file_name":"sky.jpg","project_id":623749,"asset_id":251479,"created_at":"2023-10-18T18:31:29.247+08:00","updated_at":"2023-10-18T18:31:29.247+08:00"},{"id":14020581,"file_name":"eagle.png","project_id":623749,"asset_id":251475,"created_at":"2023-10-18T18:31:29.248+08:00","updated_at":"2023-10-18T18:31:29.248+08:00"},{"id":14020582,"file_name":"koding.png","project_id":623749,"asset_id":251489,"created_at":"2023-10-18T18:31:29.248+08:00","updated_at":"2023-10-18T18:31:29.248+08:00"},{"id":14020583,"file_name":"bgm.mp3","project_id":623749,"asset_id":253598,"created_at":"2023-10-18T18:31:29.249+08:00","updated_at":"2023-10-18T18:31:29.249+08:00"},{"id":14020584,"file_name":"youwin.png","project_id":623749,"asset_id":191770,"created_at":"2023-10-18T18:31:29.251+08:00","updated_at":"2023-10-18T18:31:29.251+08:00"},{"id":14020585,"file_name":"gameover.png","project_id":623749,"asset_id":189062,"created_at":"2023-10-18T18:31:29.252+08:00","updated_at":"2023-10-18T18:31:29.252+08:00"},{"id":14020586,"file_name":"pointer.svg","project_id":623749,"asset_id":182560,"created_at":"2023-10-18T18:31:29.253+08:00","updated_at":"2023-10-18T18:31:29.253+08:00"},{"id":14020587,"file_name":"map.svg","project_id":623749,"asset_id":182559,"created_at":"2023-10-18T18:31:29.255+08:00","updated_at":"2023-10-18T18:31:29.255+08:00"},{"id":14020575,"file_name":"birdRight.png","project_id":623749,"asset_id":251480,"created_at":"2023-10-18T18:31:29.240+08:00","updated_at":"2023-10-24T13:03:04.647+08:00"},{"id":14116016,"file_name":"birdLeft.png","project_id":623749,"asset_id":691362,"created_at":"2023-10-24T13:03:08.226+08:00","updated_at":"2023-10-24T13:03:08.226+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦