{"id":781702,"student_id":10,"content":"from game import *\nfrom random import *\n\nset_backdrop('black')\nplayer = create_sprite('koding.png')\nplayer.y = 800\n\narr = []\nbullets = []\nspeed = 3\n\nfor i in range(31):\n s = create_sprite('koding.png')\n arr.append(s)\n \ndef init():\n \n for s in arr: s.number = 1\n \n # 0 ~ -1500\n for i in range(0, 15):\n arr[i].x = random() * 1200\n arr[i].y = -i * 100\n if random() \u003c 0.2: arr[i].number = 2\n if random() \u003c 0.1: arr[i].number = 3\n \n # -1500 ~ -2000\n for i in range(15, 20):\n arr[i].y = -1750\n arr[i].x = (i - 15) * 100 + 400\n arr[i].scale = 2\n \n # -2000 ~ -3500\n for i in range(20, 30):\n arr[i].x = random() * 1200\n arr[i].y = -2000 - (i - 20) * 100 \n if random() \u003c 0.2: arr[i].number = 2\n if random() \u003c 0.1: arr[i].number = 3\n \n # -4000\n arr[-1].x = random() * 1200\n arr[-1].y = -4000\n arr[-1].number = randrange(5, 10)\n arr[-1].scale = 3\n \ndef loop():\n global speed\n for s in arr: update_koding(s)\n for b in bullets: update_bullet(b)\n \n if len(bullets) \u003e 0 and bullets[0].y \u003c 0:\n bullets[0].destroy()\n bullets.pop(0)\n \n if arr[-1].y \u003e 900 or arr[-1].number == 0:\n speed += 1\n init()\n\ndef update_koding(s):\n if s.number == 0:\n s.step_forward(-speed * 4)\n elif s.y \u003c 0:\n s.y += speed\n elif s.y \u003c 800:\n s.toward(player)\n s.step_forward(speed)\n else:\n gameover()\n draw_text(s.number, s.x, s.y, 'black', 30)\n\ndef update_bullet(b):\n b.step_forward(speed * 5)\n for s in arr:\n if b.distance_to(s) \u003c 100 and not b.hidden:\n s.number -= 1\n b.hidden = True\n if b.y \u003c -100: gameover()\n\ndef gameover():\n stop()\n \ndef click():\n b = create_sprite('fish.png')\n b.move_to(player)\n b.toward(cursor)\n bullets.append(b) \n\nforever(loop)\non('click', click)\ninit()\n\n\n","created_at":"2024-07-02T01:01:39.556+08:00","updated_at":"2024-07-02T11:58:31.808+08:00","name":"叩叮飼養員","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/781702/5b5536e1e5cfcd02e41fce11fed6b59e.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":39,"hashid":"jzmszywpg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":17410952,"file_name":"fish.png","project_id":781702,"asset_id":752308,"created_at":"2024-07-02T10:54:07.683+08:00","updated_at":"2024-07-02T10:54:07.683+08:00"},{"id":17410953,"file_name":"koding.png","project_id":781702,"asset_id":752309,"created_at":"2024-07-02T10:54:07.685+08:00","updated_at":"2024-07-02T10:54:07.685+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦