{"id":695296,"student_id":10,"content":"from game import *\nfrom random import random, randint\n\nset_backdrop('black')\n\nenemy = []\nenemy_bullets = []\n\nplayer = create_sprite(\"1.png\")\nplayer_bullets = []\n\nplayer.scale = 0.3\nclock = 0\n\nfor i in range(10):\n e = create_sprite(\"0.png\", \"1.png\", \"2.png\")\n e.x = random() * 1000 + 100\n e.y = random() * 1000 * -1\n e.scale = 0.3\n e.life = 3\n enemy.append(e)\n \ndef update_enemy():\n for e in enemy:\n if e.costume_id == 0:\n e.y += 2\n if e.costume_id == 1:\n if e.hidden:\n e.y += 2\n elif e.y \u003c 200:\n e.y += 4\n if e.costume_id == 2:\n e.y += 2\n e.x += 3\n if e.x \u003e 1300: e.x -= 1400\n if e.y \u003e 900:\n e.y = random() * 1000 * -1\n e.life = 3\n e.costume_id = randint(0, 2)\n e.hidden = False\n if e.life \u003c= 0:\n e.hidden = True\n if clock % 240 == 0 and not e.hidden:\n b1 = enemy_fire(e)\n b2 = enemy_fire(e)\n b3 = enemy_fire(e)\n b2.direction += 20\n b3.direction -= 20\n \n \n\ndef update_enemy_bullet():\n for b in enemy_bullets:\n b.step_forward(5)\n \n if b.touched(player):\n b.hidden = True\n\ndef enemy_fire(e):\n b = create_sprite(\"0.png\", \"1.png\", \"2.png\")\n b.moveTo(e)\n b.scale = 0.1\n b.costume_id = e.costume_id\n b.toward(player)\n enemy_bullets.append(b)\n return b\n\ndef update_player():\n if key.left: player.x -= 5\n if key.right: player.x += 5\n if key.up: player.y -= 5\n if key.down: player.y += 5\n if key.space and clock % 10 == 0:\n b1 = player_fire()\n b2 = player_fire()\n b3 = player_fire()\n b4 = player_fire()\n b1.x -= 20\n b2.x += 20\n b3.direction -= 30\n b4.direction += 30\n \ndef update_player_bullet():\n for b in player_bullets:\n b.step_forward(10)\n if b.scale == 1:\n b.hidden = True\n b.scale = 0\n for e in enemy:\n if e.touched(b):\n e.life -= 1\n b.scale = 1\n\ndef player_fire():\n b = create_sprite(\"1.png\")\n b.moveTo(player)\n b.scale = 0.1\n b.direction = 0\n player_bullets.append(b)\n return b\n \ndef loop():\n global clock\n clock += 1\n update_enemy()\n update_player()\n update_enemy_bullet()\n update_player_bullet()\n\nforever(loop)","created_at":"2024-02-17T13:37:21.236+08:00","updated_at":"2024-02-17T15:09:18.017+08:00","name":"雷電X","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/695296/95b7d862cb974a4560bfe5a0c7f48d99.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":59,"hashid":"d5msnzv4g","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":15572002,"file_name":"0.png","project_id":695296,"asset_id":721095,"created_at":"2024-02-17T13:38:01.770+08:00","updated_at":"2024-02-17T13:38:01.770+08:00"},{"id":15572000,"file_name":"2.png","project_id":695296,"asset_id":721093,"created_at":"2024-02-17T13:38:01.236+08:00","updated_at":"2024-02-17T13:38:01.236+08:00"},{"id":15572001,"file_name":"1.png","project_id":695296,"asset_id":721094,"created_at":"2024-02-17T13:38:01.239+08:00","updated_at":"2024-02-17T13:38:01.239+08:00"},{"id":15571994,"file_name":"8.png","project_id":695296,"asset_id":721087,"created_at":"2024-02-17T13:37:58.559+08:00","updated_at":"2024-02-17T13:37:58.559+08:00"},{"id":15571995,"file_name":"7.png","project_id":695296,"asset_id":721088,"created_at":"2024-02-17T13:37:58.562+08:00","updated_at":"2024-02-17T13:37:58.562+08:00"},{"id":15571996,"file_name":"6.png","project_id":695296,"asset_id":721089,"created_at":"2024-02-17T13:37:59.656+08:00","updated_at":"2024-02-17T13:37:59.656+08:00"},{"id":15571997,"file_name":"5.png","project_id":695296,"asset_id":721090,"created_at":"2024-02-17T13:37:59.658+08:00","updated_at":"2024-02-17T13:37:59.658+08:00"},{"id":15571998,"file_name":"4.png","project_id":695296,"asset_id":721091,"created_at":"2024-02-17T13:38:00.411+08:00","updated_at":"2024-02-17T13:38:00.411+08:00"},{"id":15571999,"file_name":"3.png","project_id":695296,"asset_id":721092,"created_at":"2024-02-17T13:38:00.413+08:00","updated_at":"2024-02-17T13:38:00.413+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦