{"id":148194,"student_id":10,"content":"setBackdrop('bg.jpg'); //設定背景圖\nvar ball = createSprite( 'ball_0.png', 'ball_1.png'); //球\nvar p1 = createSprite('p1.png'); //左邊玩家擋板\nvar p2 = createSprite('p2.png'); //右邊玩家擋板\nvar info = createSprite('info.png', 'bg_1.jpg', 'bg_2.jpg'); //遊戲開始、結束提示圖\n\np1.x = 30;\np2.x = 1170;\nball.rotationStyle = 'fixed'; //球的圖片永遠保持水平,不會隨著角度改變而旋轉\n// info.hidden = true;\n\nvar p1_score = 0; //左邊玩家分數\nvar p2_score = 0; //右邊玩家分數\nvar speed = 10; //球的速度\n\ncreateSound('bgm.mp3', true);\nforever(loop); //重複不斷執行遊戲迴圈\n\n//遊戲主迴圈\nfunction loop () {\n \n if (key.o \u0026\u0026 p2.y \u003e 100) {\n p2.y -= 20;\n }\n if (key.l \u0026\u0026 p2.y \u003c 800) {\n p2.y += 20;\n }\n if (key.w \u0026\u0026 p1.y \u003e 100) {\n p1.y -= 20;\n }\n if (key.s \u0026\u0026 p1.y \u003c 800) {\n p1.y += 20;\n }\n\n //如果開始示意圖隱藏時表示遊戲開始,球才可以開始移動\n if (info.hidden) {\n ball.stepForward(speed);\n }\n if (key.space) { //按下空白按鍵隱藏開始示意圖\n info.hidden = true;\n }\n \n //上下邊界反彈\n if (ball.y \u003c 0 || ball.y \u003e 900) {\n ball.direction = -ball.direction - 180;\n }\n \n if (ball.touched(p2) \u0026\u0026 ball.direction \u003c 180) {\n ball.direction = -ball.direction + Math.random()*15;\n speed += 1;\n createSound('hit.mp3');\n }\n if (ball.touched(p1) \u0026\u0026 ball.direction \u003e 180) {\n ball.direction = -ball.direction + Math.random()*15;\n speed += 1;\n createSound('hit.mp3');\n }\n \n //如果球掉入左邊邊界,右邊玩家得分並重新發球\n if (ball.x \u003c 0) {\n ball.moveTo(600, 450);\n ball.direction = 270;\n speed = 10;\n p1_score += 1;\n createSound('lose.ogg');\n }\n //如果球掉入右邊邊界,左邊玩家得分並重新發球\n if (ball.x \u003e 1200) {\n ball.moveTo(600, 450);\n ball.direction = 90;\n speed = 10;\n p2_score += 1;\n createSound('lose.ogg');\n }\n\n drawText(p1_score, 1140, 20, '#23B0DB', 80);\n drawText(p2_score, 30, 20, '#F46F25', 80);\n\n //左邊玩家獲勝\n if (p1_score == 5) {\n info.costumeId = 1;\n info.hidden = false;\n stop();\n }\n //右邊玩家獲勝\n if (p2_score == 5) {\n info.costumeId = 2;\n info.hidden = false;\n stop();\n }\n if (speed \u003c 15) {\n ball.costumeId = 0;\n } else {\n ball.costumeId = 1;\n }\n}","created_at":"2020-05-13T21:35:48.930+08:00","updated_at":"2020-08-20T13:23:43.288+08:00","name":"彈力球大賽(完整版)","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/148194/05a9a79a755c349cc1f500be50655a20.jpg"},"parent_id":2,"plugin":"Game.set({ width: 1200, height: 900 })\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":245,"hashid":"p93s2ddg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3115830,"file_name":"ball_2.png","project_id":148194,"asset_id":251354,"created_at":"2020-08-20T13:21:53.531+08:00","updated_at":"2020-08-20T13:21:53.531+08:00"},{"id":3115831,"file_name":"ball_3.png","project_id":148194,"asset_id":251355,"created_at":"2020-08-20T13:21:53.533+08:00","updated_at":"2020-08-20T13:21:53.533+08:00"},{"id":3115832,"file_name":"bg_1.jpg","project_id":148194,"asset_id":251356,"created_at":"2020-08-20T13:21:53.851+08:00","updated_at":"2020-08-20T13:21:53.851+08:00"},{"id":3115833,"file_name":"bg_2.jpg","project_id":148194,"asset_id":251357,"created_at":"2020-08-20T13:21:53.852+08:00","updated_at":"2020-08-20T13:21:53.852+08:00"},{"id":3115834,"file_name":"bg.jpg","project_id":148194,"asset_id":251358,"created_at":"2020-08-20T13:21:54.016+08:00","updated_at":"2020-08-20T13:21:54.016+08:00"},{"id":3115835,"file_name":"info.png","project_id":148194,"asset_id":251359,"created_at":"2020-08-20T13:21:54.018+08:00","updated_at":"2020-08-20T13:21:54.018+08:00"},{"id":3115836,"file_name":"p1.png","project_id":148194,"asset_id":251360,"created_at":"2020-08-20T13:21:54.172+08:00","updated_at":"2020-08-20T13:21:54.172+08:00"},{"id":3115837,"file_name":"p2.png","project_id":148194,"asset_id":251361,"created_at":"2020-08-20T13:21:54.173+08:00","updated_at":"2020-08-20T13:21:54.173+08:00"},{"id":3115828,"file_name":"ball_0.png","project_id":148194,"asset_id":251352,"created_at":"2020-08-20T13:21:53.310+08:00","updated_at":"2020-08-20T13:21:53.310+08:00"},{"id":3115829,"file_name":"ball_1.png","project_id":148194,"asset_id":251353,"created_at":"2020-08-20T13:21:53.311+08:00","updated_at":"2020-08-20T13:21:53.311+08:00"},{"id":3115816,"file_name":"bgm.mp3","project_id":148194,"asset_id":251340,"created_at":"2020-08-20T13:21:16.548+08:00","updated_at":"2020-08-20T13:21:16.548+08:00"},{"id":3115817,"file_name":"hit.mp3","project_id":148194,"asset_id":251341,"created_at":"2020-08-20T13:21:16.553+08:00","updated_at":"2020-08-20T13:21:16.553+08:00"},{"id":3115818,"file_name":"lose.ogg","project_id":148194,"asset_id":251342,"created_at":"2020-08-20T13:21:16.557+08:00","updated_at":"2020-08-20T13:21:16.557+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦