{"id":78334,"student_id":10,"content":"var player;\nvar balls = [];\nvar score = 0;\nvar clock = 0;\n\nfunction createTarget (x, y) {\n var t = createSprite(['target_3.png','target_4.png','target_5.png']);\n t.moveTo(x, y);\n t.clock = 0;\n t.scale = 0.6;\n t.forever(function () {\n t.clock++;\n \n if (t.clock == 10) {\n t.costumeId = 1;\n }\n if (t.clock == 20) {\n t.costumeId = 2;\n }\n if (t.clock == 30) {\n t.destroy();\n }\n });\n}\n\nfunction fire () {\n var b = createSprite('bullet.png');\n b.moveTo(player);\n b.direction = 0;\n b.forever(function () {\n b.stepForward(8);\n if (b.y \u003c 0) b.destroy();\n });\n \n b.on('touch', balls, function (target) {\n target.life--;\n b.destroy();\n })\n}\n\nfunction createBall () {\n let b = createSprite(['ball_1.png','ball_2.png','ball_3.png']);\n \n\n b.reset = function () {\n b.scale = 1.3;\n b.costumeId = Math.floor(Math.random()*3);\n b.vy = 0;\n b.vx = 0;\n b.life = 3;\n b.freeze = true;\n b.moveTo(Math.random()*640, -35);\n setTimeout(function() { b.freeze = false }, 1000 + Math.random()*3000);\n }\n b.forever(function() {\n if (b.freeze) return;\n b.vy += 0.35;\n b.y += b.vy;\n b.x -= b.vx;\n if (b.y \u003e 400) {\n b.y -= b.vy;\n b.vy = -b.vy;\n if (b.vx == 0) {\n b.vx = Math.random() \u003e 0.5 ? 5: -5;\n b.vy *= 0.85;\n }\n }\n\n if (b.x \u003c 0 || b.x \u003e 640) {\n b.vx *= -1;\n }\n if (b.life \u003c= 0) {\n createTarget(b.x, b.y);\n b.reset();\n score += 30;\n }\n });\n b.reset();\n return b;\n}\n\n\nsetBackdrop(\"bg.png\", 0, 0, 640, 480);\n\nvar startBtn = createSprite(\"start.svg\");\nstartBtn.vd = 2;\nstartBtn.forever(function () {\n if (startBtn.direction \u003e 120) {\n startBtn.vd = -2;\n }\n if (startBtn.direction \u003c 60) {\n startBtn.vd = +2;\n }\n startBtn.direction += startBtn.vd; \n});\nstartBtn.on('click', function (){\n startBtn.destroy();\n \n player = createSprite(\"player.png\");\n player.moveTo(332, 375);\n player.scale = 0.7;\n player.power = 0;\n \n balls = [createBall(), createBall(), createBall()];\n \n forever(function() {\n if ((key.d || key.right) \u0026\u0026 player.x \u003c 640) {\n player.x += 8;\n player.power++;\n }\n if ((key.a || key.left) \u0026\u0026 player.x \u003e 0) {\n player.x -= 8;\n player.power++;\n }\n if (player.power \u003e 6) {\n fire();\n player.power = 0;\n }\n clock++;\n if (clock%60==0) {\n score++;\n }\n print('分數: ' +score, 10, 10, 'red', 30)\n });\n player.on('touch', balls, stop);\n});\n\n\n\n\n\n\n\n\n\n","created_at":"2019-07-11T13:50:28.592+08:00","updated_at":"2019-10-26T13:36:07.448+08:00","name":"擊落星球","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/78334/89edcce60b8890776f43b51e69f48ea4.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":296,"hashid":"ej9skqy6","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1345350,"file_name":"start.svg","project_id":78334,"asset_id":132998,"created_at":"2019-07-11T17:51:30.975+08:00","updated_at":"2019-07-11T17:51:30.975+08:00"},{"id":1345351,"file_name":"target_6.png","project_id":78334,"asset_id":132999,"created_at":"2019-07-11T17:51:30.978+08:00","updated_at":"2019-07-11T17:51:30.978+08:00"},{"id":1345352,"file_name":"bullet.png","project_id":78334,"asset_id":133000,"created_at":"2019-07-11T17:51:30.981+08:00","updated_at":"2019-07-11T17:51:30.981+08:00"},{"id":1345353,"file_name":"bg.wav","project_id":78334,"asset_id":133001,"created_at":"2019-07-11T17:51:30.984+08:00","updated_at":"2019-07-11T17:51:30.984+08:00"},{"id":1345354,"file_name":"target_1.png","project_id":78334,"asset_id":133002,"created_at":"2019-07-11T17:51:30.987+08:00","updated_at":"2019-07-11T17:51:30.987+08:00"},{"id":1345355,"file_name":"target_2.png","project_id":78334,"asset_id":133003,"created_at":"2019-07-11T17:51:30.990+08:00","updated_at":"2019-07-11T17:51:30.990+08:00"},{"id":1345356,"file_name":"target_3.png","project_id":78334,"asset_id":133004,"created_at":"2019-07-11T17:51:30.993+08:00","updated_at":"2019-07-11T17:51:30.993+08:00"},{"id":1345357,"file_name":"target_4.png","project_id":78334,"asset_id":133005,"created_at":"2019-07-11T17:51:30.996+08:00","updated_at":"2019-07-11T17:51:30.996+08:00"},{"id":1345358,"file_name":"target_5.png","project_id":78334,"asset_id":133006,"created_at":"2019-07-11T17:51:31.000+08:00","updated_at":"2019-07-11T17:51:31.000+08:00"},{"id":1345359,"file_name":"player.png","project_id":78334,"asset_id":133007,"created_at":"2019-07-11T17:51:31.003+08:00","updated_at":"2019-07-11T17:51:31.003+08:00"},{"id":1345360,"file_name":"bg.png","project_id":78334,"asset_id":133008,"created_at":"2019-07-11T17:51:31.006+08:00","updated_at":"2019-07-11T17:51:31.006+08:00"},{"id":1345361,"file_name":"ball_1.png","project_id":78334,"asset_id":133009,"created_at":"2019-07-11T17:51:31.009+08:00","updated_at":"2019-07-11T17:51:31.009+08:00"},{"id":1345362,"file_name":"ball_2.png","project_id":78334,"asset_id":133010,"created_at":"2019-07-11T17:51:31.012+08:00","updated_at":"2019-07-11T17:51:31.012+08:00"},{"id":1345363,"file_name":"ball_3.png","project_id":78334,"asset_id":133011,"created_at":"2019-07-11T17:51:31.015+08:00","updated_at":"2019-07-11T17:51:31.015+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦