{"id":523766,"student_id":26492,"content":"setBackdrop(\"#222222\");\nvar player = createSprite(\"player.png\"); // 建立玩家檔板\nvar ball = createSprite(\"ball.png\"); // 建立球\nvar score = 0;\nvar lives = 3;\nvar speed = 5;\nvar level = 1;\nvar blocks = [];\n\nplayer.y = 450;\nball.direction = 180;\n\ninitBlocks();\n\nforever(function () {\n if(lives \u003e 0){\n player.x = cursor.x;\n updateBall(); \n }else{\n print('Game Over', 170, 200, 'white, 60');\n }\n \n print(\"Score: \" + score, 20, 20, \"white\");\n print(\"Lives: \" + lives, 20, 40, \"white\");\n print(\"Level: \" + level, 20, 60, \"white\");\n});\n\n\n\n\nfunction initBlocks() {\n for (var j = 0; j \u003c 3; j++) {\n //用迴圈重複執行十次\n for (var i = 0; i \u003c 10; i++) {\n //創造角色(六個)\n var block = createSprite([\"b0.png\", \"b1.png\", \"b2.png\", \"b3.png\", \"b4.png\", \"b5.png\",]);\n //角色隨機造型( 1 ~ 5取整數)\n block.costumeId = Math.floor(Math.random()*6);\n //磚塊的x\n block.x = 32 + i * 64;\n //磚塊的y\n block.y = 16 + j * 32;\n //加入陣列\n blocks.push(block);\n }\n }\n}\n\nfunction updateBall(){\n //求前線speed步\n ball.stepForward(speed);\n //if(碰到左邊界or右邊界)\n if(ball.x \u003c= 0 || ball.x \u003e= 640){\n //反彈(後來的方向 = -原來的方向)\n ball.direction = -ball.direction;\n }\n if(ball.y \u003c= 0){\n ball.direction = -ball.direction + 180;\n }\n if(ball.y \u003e= 480){\n ball.x = 320;\n ball.y = 240;\n ball.direction = 180;\n speed = 5;\n lives--;\n }\n}\n\nball.on('touch', player, function(){\n //球反彈(公式: B = -A + 180),and 加上隨機角度 -15 ~ 15\n ball.direction = -ball.direction + 180 + Math.random() *30 - 15;\n //球的座標 = 擋板的y -30\n ball.y = player.y - 30;\n});\n\nball.on('touch', blocks, function(block){\n //球反彈(公式: B = -A + 180),and 加上隨機角度 -15 ~ 15\n ball.direction = -ball.direction + 180 + Math.random() *30 - 15;\n block.destroy();\n score++;\n \n if(score % 30 === 0){\n initBlocks();\n level++;\n }\n if(score % 3 === 0 \u0026\u0026 speed \u003c 15){\n speed++;\n }\n});\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfor (var j = 0; j \u003c 3; j++) {\n for (var i = 0; i \u003c 10; i++) {\n console.log(j);\n console.log(i);\n }\n console.log('--------------------');\n}","created_at":"2023-04-25T19:05:00.894+08:00","updated_at":"2023-04-25T21:06:02.515+08:00","name":"breakout 副本","language":"javascript","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/523766/ecfc767f5522118662ba79540c5f001e.jpg"},"parent_id":60761,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":9,"hashid":"vngs5q8qv","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":11930843,"file_name":"player.png","project_id":523766,"asset_id":113019,"created_at":"2023-04-25T19:05:00.899+08:00","updated_at":"2023-04-25T19:05:00.899+08:00"},{"id":11930844,"file_name":"ball.png","project_id":523766,"asset_id":113020,"created_at":"2023-04-25T19:05:00.900+08:00","updated_at":"2023-04-25T19:05:00.900+08:00"},{"id":11930845,"file_name":"b0.png","project_id":523766,"asset_id":113021,"created_at":"2023-04-25T19:05:00.901+08:00","updated_at":"2023-04-25T19:05:00.901+08:00"},{"id":11930846,"file_name":"b1.png","project_id":523766,"asset_id":113022,"created_at":"2023-04-25T19:05:00.902+08:00","updated_at":"2023-04-25T19:05:00.902+08:00"},{"id":11930847,"file_name":"b2.png","project_id":523766,"asset_id":113023,"created_at":"2023-04-25T19:05:00.903+08:00","updated_at":"2023-04-25T19:05:00.903+08:00"},{"id":11930848,"file_name":"b3.png","project_id":523766,"asset_id":113024,"created_at":"2023-04-25T19:05:00.904+08:00","updated_at":"2023-04-25T19:05:00.904+08:00"},{"id":11930849,"file_name":"b4.png","project_id":523766,"asset_id":113025,"created_at":"2023-04-25T19:05:00.905+08:00","updated_at":"2023-04-25T19:05:00.905+08:00"},{"id":11930850,"file_name":"b5.png","project_id":523766,"asset_id":113026,"created_at":"2023-04-25T19:05:00.906+08:00","updated_at":"2023-04-25T19:05:00.906+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦