{"id":194864,"student_id":10,"content":"import game\nimport random\n\ngame.set_backdrop('black')\n\nplayer = game.create_sprite('ship.png')\nleader = game.create_sprite('redInvader.png')\nbullet = game.create_sprite('bullet.png')\n\nleader.y = 100\nplayer.move_to(600, 800)\nbullet.move_to(player)\n\nenemies = []\nenemies_bullets = []\n\nclock = 0\nlife = 3\n\nfor x in range(9):\n for y in range(5):\n if y % 2 == 0: e = game.create_sprite('invader_a1.png', 'invader_a2.png')\n else: e = game.create_sprite('invader_b1.png', 'invader_b2.png')\n e.x = x * 80 + 50\n e.y = y * 50 + 150\n enemies.append(e)\n\n\ngame.create_sound('bgm.mp3', True)\n\ndef loop():\n global vx, clock, life\n \n if game.key.right: player.x += 5\n if game.key.left: player.x -= 5\n \n if game.key.space and bullet.hidden == True:\n bullet.hidden = False\n bullet.move_to(player)\n game.create_sound('shot.mp3')\n \n bullet.y -= 13\n if bullet.y \u003c 0: bullet.hidden = True\n \n clock += 1\n for e in enemies: \n if clock % 1800 \u003c 600: e.x += 0.2 \n elif clock % 1800 \u003c 900: e.y += 0.2\n elif clock % 1800 \u003c 1500: e.x -= 0.2\n else: e.y += 0.2\n \n e.costume_id = int(clock / 30) % 2\n \n if random.randrange(10000) \u003c 5:\n s = game.create_sprite('bullet.png')\n s.move_to(e)\n enemies_bullets.append(s)\n \n if bullet.touched(e):\n e.destroy()\n bullet.hidden = True\n game.create_sound('boom.mp3')\n \n for s in enemies_bullets:\n s.y += 8\n if s.touched(player):\n life -= 1\n s.destroy()\n \n if len(enemies_bullets) \u003e 20:\n del enemies_bullets[0]\n \n \n if life \u003c= 0: game.stop()\n \n game.draw_text('life:' + str(life), 10, 10, 'white', 40)\n \n leader.x -= 8\n if leader.x \u003c -100:\n leader.x += 3000\n leader.y += 50\n if leader.touched(bullet):\n leader.destroy()\n bullet.hidden = True\n game.create_sound('boom.mp3')\n \ngame.forever(loop)","created_at":"2020-10-14T14:31:13.909+08:00","updated_at":"2021-07-07T12:45:24.978+08:00","name":"太空侵略者(概念版)","language":"python","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/194864/d1df25b2738683732bd80fb77933492e.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":227,"hashid":"5j3s9nnqv","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3505401,"file_name":"bullet.png","project_id":194864,"asset_id":280637,"created_at":"2020-11-10T17:35:11.143+08:00","updated_at":"2020-11-10T17:35:11.143+08:00"},{"id":3505402,"file_name":"full_block.png","project_id":194864,"asset_id":280638,"created_at":"2020-11-10T17:35:11.145+08:00","updated_at":"2020-11-10T17:35:11.145+08:00"},{"id":3505403,"file_name":"invader_a1.png","project_id":194864,"asset_id":280639,"created_at":"2020-11-10T17:35:11.716+08:00","updated_at":"2020-11-10T17:35:11.716+08:00"},{"id":3505404,"file_name":"invader_a2.png","project_id":194864,"asset_id":280640,"created_at":"2020-11-10T17:35:11.717+08:00","updated_at":"2020-11-10T17:35:11.717+08:00"},{"id":3505405,"file_name":"invader_b1.png","project_id":194864,"asset_id":280641,"created_at":"2020-11-10T17:35:12.233+08:00","updated_at":"2020-11-10T17:35:12.233+08:00"},{"id":3505406,"file_name":"invader_b2.png","project_id":194864,"asset_id":280642,"created_at":"2020-11-10T17:35:12.235+08:00","updated_at":"2020-11-10T17:35:12.235+08:00"},{"id":3505407,"file_name":"invader_c1.png","project_id":194864,"asset_id":280643,"created_at":"2020-11-10T17:35:12.756+08:00","updated_at":"2020-11-10T17:35:12.756+08:00"},{"id":3505408,"file_name":"invader_c2.png","project_id":194864,"asset_id":280644,"created_at":"2020-11-10T17:35:12.757+08:00","updated_at":"2020-11-10T17:35:12.757+08:00"},{"id":3505409,"file_name":"block.png","project_id":194864,"asset_id":280645,"created_at":"2020-11-10T17:35:13.254+08:00","updated_at":"2020-11-10T17:35:13.254+08:00"},{"id":3505410,"file_name":"redInvader.png","project_id":194864,"asset_id":280646,"created_at":"2020-11-10T17:35:13.255+08:00","updated_at":"2020-11-10T17:35:13.255+08:00"},{"id":3505411,"file_name":"ship.png","project_id":194864,"asset_id":280647,"created_at":"2020-11-10T17:35:13.769+08:00","updated_at":"2020-11-10T17:35:13.769+08:00"},{"id":3505412,"file_name":"ShipCrushedLeft.png","project_id":194864,"asset_id":280648,"created_at":"2020-11-10T17:35:13.770+08:00","updated_at":"2020-11-10T17:35:13.770+08:00"},{"id":3505413,"file_name":"ShipCrushedRight.png","project_id":194864,"asset_id":280649,"created_at":"2020-11-10T17:35:14.247+08:00","updated_at":"2020-11-10T17:35:14.247+08:00"},{"id":3505414,"file_name":"weak_block.png","project_id":194864,"asset_id":280650,"created_at":"2020-11-10T17:35:14.249+08:00","updated_at":"2020-11-10T17:35:14.249+08:00"},{"id":3505416,"file_name":"bgm.mp3","project_id":194864,"asset_id":280651,"created_at":"2020-11-10T18:06:29.493+08:00","updated_at":"2020-11-10T18:06:34.098+08:00"},{"id":3505417,"file_name":"shot.mp3","project_id":194864,"asset_id":280652,"created_at":"2020-11-10T18:10:05.778+08:00","updated_at":"2020-11-10T18:10:05.778+08:00"},{"id":3505418,"file_name":"boom.mp3","project_id":194864,"asset_id":280653,"created_at":"2020-11-10T18:10:07.689+08:00","updated_at":"2020-11-10T18:10:07.689+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦