{"id":182996,"student_id":10,"content":"/**\n * 情境:老師我的程式無法執行...\n * 提示:搜尋關鍵字詞\n */\n\nvar score_left = 0;\nvar score_right = 0;\nvar speed = 5;\n\nforever(function() {\n\n ball.stepforward(speed); //向前移動\n\n //當球撞到上下邊界時反彈\n if (ball.y \u003c 0 || ball.y \u003e 480) {\n ball.direction = -ball.direction - 180; //上下邊界反彈\n }\n\n //當球撞到兩邊擋板時反彈\n if (ball.touched(p2) || ball.touched(p1)) {\n ball.direction = -ball.direction + Math.random()*15; //左右擋板反彈\n speed = speed + 0.5;\n }\n \n if (key.up) {\n p1.y = p1.y - 10;\n }\n if (key.down) {\n p1.y = p1.y + 10;\n }\n if (key.w) {\n p2.y = p2.y - 10;\n }\n if (key.s) {\n p2.y = p2.y + 10;\n }\n \n //當球掉入右邊邊界\n if (ball.x \u003c 0) {\n score_right = score_right + 1; //右邊玩家得分\n ball.direction = 270;\n }\n //當球掉入左邊邊界\n if (ball.x \u003e 640) {\n score_left = score_left + 1; //左邊玩家得分\n ball.direction = 90;\n }\n \n //當球掉入雙方邊界時,重置球\n if (ball.x \u003c 0 || ball.x \u003e 640) {\n ball.x = 320;\n ball.y = 240;\n speed = 5;\n }\n \n print(score_left, 30, 20, '#157df9', 40);\n print(score_right, 580, 20, '#fd7e24', 40);\n});","created_at":"2020-08-19T15:37:13.493+08:00","updated_at":"2022-11-02T15:10:41.626+08:00","name":"L5_彈力球大戰_除錯範例","language":"javascript","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/182996/b230fa3bcc0fafe3f75ee57f07ce202f.jpg"},"parent_id":73437,"plugin":"setBackdrop('bg.jpg');\nvar ball = createSprite(\"ball.png\");\nvar p2 = createSprite({\n costumes: \"blue.jpg\",\n x: 10,\n y: 250\n});\nvar p1 = createSprite({\n costumes: \"orange.jpg\",\n x: 631,\n y: 250\n});\n// =================================//\n\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":257,"hashid":"rdvsqke4","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3112718,"file_name":"BonusCube.mp3","project_id":182996,"asset_id":127563,"created_at":"2020-08-19T15:37:13.501+08:00","updated_at":"2020-08-19T15:37:13.501+08:00"},{"id":3112719,"file_name":"bg.jpg","project_id":182996,"asset_id":127562,"created_at":"2020-08-19T15:37:13.503+08:00","updated_at":"2020-08-19T15:37:13.503+08:00"},{"id":3112720,"file_name":"ball.png","project_id":182996,"asset_id":127561,"created_at":"2020-08-19T15:37:13.505+08:00","updated_at":"2020-08-19T15:37:13.505+08:00"},{"id":3112721,"file_name":"orange.jpg","project_id":182996,"asset_id":127560,"created_at":"2020-08-19T15:37:13.507+08:00","updated_at":"2020-08-19T15:37:13.507+08:00"},{"id":3112722,"file_name":"blue.jpg","project_id":182996,"asset_id":127559,"created_at":"2020-08-19T15:37:13.508+08:00","updated_at":"2020-08-19T15:37:13.508+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦