{"id":183187,"student_id":2589,"content":"","created_at":"2020-08-20T11:15:43.270+08:00","updated_at":"2020-08-20T11:16:12.573+08:00","name":"彈力球大賽(完整版)","language":"javascript","screenshot":{"url":null},"parent_id":2,"plugin":"Game.set({ width: 1200, height: 900 })\n\nsetBackdrop('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 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 if (ball.y \u003c 0 || ball.y \u003e 900) {\n ball.direction = -ball.direction - 180;\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}\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":67,"hashid":"qmdsny2v","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3115471,"file_name":"bgm.mp3","project_id":183187,"asset_id":251250,"created_at":"2020-08-20T11:15:58.874+08:00","updated_at":"2020-08-20T11:15:58.874+08:00"},{"id":3115472,"file_name":"hit.mp3","project_id":183187,"asset_id":251251,"created_at":"2020-08-20T11:15:58.879+08:00","updated_at":"2020-08-20T11:15:58.879+08:00"},{"id":3115473,"file_name":"lose.ogg","project_id":183187,"asset_id":251252,"created_at":"2020-08-20T11:15:58.886+08:00","updated_at":"2020-08-20T11:15:58.886+08:00"},{"id":3115474,"file_name":"bg.jpg","project_id":183187,"asset_id":251253,"created_at":"2020-08-20T11:15:58.895+08:00","updated_at":"2020-08-20T11:15:58.895+08:00"},{"id":3115475,"file_name":"bg_1.jpg","project_id":183187,"asset_id":251254,"created_at":"2020-08-20T11:15:58.901+08:00","updated_at":"2020-08-20T11:15:58.901+08:00"},{"id":3115476,"file_name":"bg_2.jpg","project_id":183187,"asset_id":251255,"created_at":"2020-08-20T11:15:58.907+08:00","updated_at":"2020-08-20T11:15:58.907+08:00"},{"id":3115477,"file_name":"ball_0.png","project_id":183187,"asset_id":251256,"created_at":"2020-08-20T11:15:58.912+08:00","updated_at":"2020-08-20T11:15:58.912+08:00"},{"id":3115478,"file_name":"info.png","project_id":183187,"asset_id":251257,"created_at":"2020-08-20T11:15:58.916+08:00","updated_at":"2020-08-20T11:15:58.916+08:00"},{"id":3115479,"file_name":"ball_1.png","project_id":183187,"asset_id":251258,"created_at":"2020-08-20T11:15:58.920+08:00","updated_at":"2020-08-20T11:15:58.920+08:00"},{"id":3115480,"file_name":"ball_3.png","project_id":183187,"asset_id":251259,"created_at":"2020-08-20T11:15:58.924+08:00","updated_at":"2020-08-20T11:15:58.924+08:00"},{"id":3115481,"file_name":"p2.png","project_id":183187,"asset_id":251260,"created_at":"2020-08-20T11:15:58.928+08:00","updated_at":"2020-08-20T11:15:58.928+08:00"},{"id":3115482,"file_name":"p1.png","project_id":183187,"asset_id":251261,"created_at":"2020-08-20T11:15:58.932+08:00","updated_at":"2020-08-20T11:15:58.932+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦