{"id":233662,"student_id":10,"content":"setBackdrop('black')\nlet player = createSprite('ship.png')\nlet leader = createSprite('redInvader.png', 'redInvader.png', 'redInvader.png', 'redInvader.png')\nlet bullet = createSprite('bullet.png')\nlet enemies = []\nlet enemies_bullets = []\nlet clock = 0\nlet life = 10\nlet count = 0;\nlet vx = 8;\nlet score = 0;\n\nleader.y = 45;\nplayer.moveTo(600, 800)\nbullet.moveTo(player)\ncreateSound('bgm.mp3', true)\ninit();\n\nplayer.scale = leader.scale = 1.4;\n\nfunction loop() {\n clock += 0.5\n updatePlayer();\n updateEnemies();\n updateLeader();\n updateBullets();\n updateInfo();\n}\n\nfunction init () {\n enemies.length = 0;\n count = 0;\n clock = 0;\n leader.hidden = false;\n leader.costumeId = 0;\n for (let x = 0; x \u003c 10; x++) {\n for (let y = 0; y \u003c 5; y++) {\n if (y % 2 == 0) e = createSprite('invader_a1.png', 'invader_a2.png')\n else e = createSprite('invader_b1.png', 'invader_b2.png')\n e.x = x * 90 + 45;\n e.y = y * 45 + 112.5;\n e.scale = 1.4;\n enemies.push(e);\n }\n }\n}\n\nfunction updatePlayer () {\n if (key.right) player.x += 4\n if (key.left) player.x -= 4\n if (key.up \u0026\u0026 bullet.hidden == true) {\n bullet.hidden = false;\n bullet.moveTo(player);\n createSound('shot.mp3');\n }\n bullet.y -= 13\n if (bullet.y \u003c 0) bullet.hidden = true;\n}\n\nfunction updateEnemies() {\n for (let i = 0; i \u003c enemies.length; i++) {\n let e = enemies[i];\n if (clock % 780 \u003c 300) e.x += 0.5\n else if (clock % 780 \u003c 390) e.y += 0.5\n else if (clock % 780 \u003c 690) e.x -= 0.5\n else e.y += 0.5\n\n if (bullet.touched(e)) {\n e.destroy();\n bullet.hidden = true;\n createSound('boom.mp3');\n count++;\n score += 10;\n }\n e.costumeId = Math.floor(clock / 30) % 2;\n }\n}\n\nfunction updateBullets () {\n for (let i = 0; i \u003c enemies_bullets.length; i++) {\n let s = enemies_bullets[i]\n s.y += 10;\n if (s.touched(player)) {\n life -= 1\n s.destroy()\n }\n }\n}\n\nfunction updateLeader() {\n leader.x += vx;\n if (leader.x \u003c -100) vx = +8;\n if (leader.x \u003e 1300) vx = -8;\n if (leader.touched(bullet)) {\n leader.costumeId += 1;\n createSound('boom.mp3')\n }\n if (leader.costumeId == 3 \u0026\u0026 leader.hidden == false) {\n leader.hidden = true;\n score += 300;\n }\n if (Math.random() \u003c 0.05 \u0026\u0026 leader.hidden == false) {\n let s = createSprite('bullet.png')\n s.moveTo(leader)\n enemies_bullets.push(s)\n }\n}\n\nfunction updateInfo () {\n if (count == 50 \u0026\u0026 leader.hidden) init();\n if (life \u003c= 0) stop()\n drawText('life:' + life, 40, 40, 'white', 40);\n drawText('score:' + score, 40, 50, 'white', 40);\n}\n\nforever(loop)","created_at":"2021-03-08T17:59:02.701+08:00","updated_at":"2022-02-16T15:04:47.638+08:00","name":"太空侵略者","language":"javascript","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/233662/f8ec607c541d08cc0d4099dfda555d71.jpg"},"parent_id":2,"plugin":"Game.set({\n width: 1200, height: 900\n})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":207,"hashid":"4y3sg33vm","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":4215788,"file_name":"boom.mp3","project_id":233662,"asset_id":280653,"created_at":"2021-03-08T17:59:24.445+08:00","updated_at":"2021-03-08T17:59:24.445+08:00"},{"id":4215789,"file_name":"bullet.png","project_id":233662,"asset_id":280637,"created_at":"2021-03-08T17:59:24.447+08:00","updated_at":"2021-03-08T17:59:24.447+08:00"},{"id":4215798,"file_name":"ship.png","project_id":233662,"asset_id":280647,"created_at":"2021-03-08T17:59:26.891+08:00","updated_at":"2021-03-08T17:59:26.891+08:00"},{"id":4215799,"file_name":"ShipCrushedLeft.png","project_id":233662,"asset_id":280648,"created_at":"2021-03-08T17:59:26.893+08:00","updated_at":"2021-03-08T17:59:26.893+08:00"},{"id":4215796,"file_name":"invader_c2.png","project_id":233662,"asset_id":280644,"created_at":"2021-03-08T17:59:26.431+08:00","updated_at":"2021-03-08T17:59:26.431+08:00"},{"id":4215797,"file_name":"redInvader.png","project_id":233662,"asset_id":280646,"created_at":"2021-03-08T17:59:26.433+08:00","updated_at":"2021-03-08T17:59:26.433+08:00"},{"id":4215786,"file_name":"bgm.mp3","project_id":233662,"asset_id":280651,"created_at":"2021-03-08T17:59:23.917+08:00","updated_at":"2021-03-08T17:59:23.917+08:00"},{"id":4215787,"file_name":"block.png","project_id":233662,"asset_id":280645,"created_at":"2021-03-08T17:59:23.920+08:00","updated_at":"2021-03-08T17:59:23.920+08:00"},{"id":4215790,"file_name":"full_block.png","project_id":233662,"asset_id":280638,"created_at":"2021-03-08T17:59:24.961+08:00","updated_at":"2021-03-08T17:59:24.961+08:00"},{"id":4215791,"file_name":"invader_a1.png","project_id":233662,"asset_id":280639,"created_at":"2021-03-08T17:59:24.962+08:00","updated_at":"2021-03-08T17:59:24.962+08:00"},{"id":4215792,"file_name":"invader_a2.png","project_id":233662,"asset_id":280640,"created_at":"2021-03-08T17:59:25.441+08:00","updated_at":"2021-03-08T17:59:25.441+08:00"},{"id":4215793,"file_name":"invader_b1.png","project_id":233662,"asset_id":280641,"created_at":"2021-03-08T17:59:25.443+08:00","updated_at":"2021-03-08T17:59:25.443+08:00"},{"id":4215800,"file_name":"ShipCrushedRight.png","project_id":233662,"asset_id":280649,"created_at":"2021-03-08T17:59:27.430+08:00","updated_at":"2021-03-08T17:59:27.430+08:00"},{"id":4215801,"file_name":"shot.mp3","project_id":233662,"asset_id":280652,"created_at":"2021-03-08T17:59:27.432+08:00","updated_at":"2021-03-08T17:59:27.432+08:00"},{"id":4215794,"file_name":"invader_b2.png","project_id":233662,"asset_id":280642,"created_at":"2021-03-08T17:59:25.959+08:00","updated_at":"2021-03-08T17:59:25.959+08:00"},{"id":4215795,"file_name":"invader_c1.png","project_id":233662,"asset_id":280643,"created_at":"2021-03-08T17:59:25.961+08:00","updated_at":"2021-03-08T17:59:25.961+08:00"},{"id":4215802,"file_name":"weak_block.png","project_id":233662,"asset_id":280650,"created_at":"2021-03-08T17:59:27.917+08:00","updated_at":"2021-03-08T17:59:27.917+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦