{"id":695304,"student_id":10,"content":"from game import *\nfrom random import random, randint\n\npaths = []\nballs = []\npos = [(100, 100), (1100, 100), (200, 200), (1000, 200), (300, 300)]\nflying = False\n\nmyball = create_sprite('0.png', '1.png', '2.png')\nmyball.y = 800\n\nfor p in pos:\n s = create_sprite('4.png')\n s.x = p[0]\n s.y = p[1]\n paths.append(s)\n\nfor i in range(20):\n s = create_sprite('0.png', '1.png', '2.png')\n s.costume_id = randint(0, 2)\n s.move_to(100, 100)\n s.y += i * 50\n s.target = 0\n balls.append(s)\n \ndef move(b, step = 3, is_back = False):\n target = paths[b.target - 1 if is_back else b.target] \n dist = b.distance_to(target)\n b.toward(target)\n if dist \u003c step:\n b.move_to(target)\n b.target += -1 if is_back else 1\n b.target = b.target % len(paths)\n b.step_forward(step - dist)\n else:\n b.step_forward(step)\n \ndef click():\n global flying\n myball.toward(cursor)\n flying = True\n \ndef insert(index):\n global balls\n \n t = balls[index]\n s = create_sprite('0.png', '1.png', '2.png')\n s.target = t.target\n s.moveTo(t)\n s.costume_id = myball.costume_id\n for b in balls[index:]:\n move(b, 50, True)\n balls.insert(index, s)\n \n \n s = index\n e = index\n for i in range(1, 100):\n if s - 1 \u003e= 0 and balls[s - 1].costume_id == balls[index].costume_id:\n s -= 1\n else: break\n for i in range(1, 100):\n if e + 1 \u003c len(balls) and balls[e + 1].costume_id == balls[index].costume_id:\n e += 1\n else: break\n \n if e - s \u003e= 2:\n d = (e - s + 1) * 50 / 2\n for i in range(s, e + 1):\n balls[i].destroy()\n for b in balls[:s]:\n move(b, d, True)\n for b in balls[e:]:\n move(b, d)\n balls = balls[:s] + balls[e:]\n \ndef loop():\n global flying\n for index, b in enumerate(balls):\n if key.space:\n move(b, 2, True)\n else:\n move(b, 2)\n if b.touched(myball):\n insert(index)\n myball.move_to(600, 800)\n myball.costume_id = randint(0, 2)\n flying = False\n if flying:\n myball.step_forward(30)\n\non('click', click)\nforever(loop)\n\n","created_at":"2024-02-17T15:36:28.600+08:00","updated_at":"2024-03-20T15:23:54.592+08:00","name":"Zuma","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/695304/855d599ceec88316db9be54377f0eeb4.jpg"},"parent_id":694989,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":58,"hashid":"kdms8m6en","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":15572037,"file_name":"5.png","project_id":695304,"asset_id":721179,"created_at":"2024-02-17T15:36:28.607+08:00","updated_at":"2024-02-17T15:36:28.607+08:00"},{"id":15572038,"file_name":"4.png","project_id":695304,"asset_id":721180,"created_at":"2024-02-17T15:36:28.609+08:00","updated_at":"2024-02-17T15:36:28.609+08:00"},{"id":15572039,"file_name":"3.png","project_id":695304,"asset_id":721181,"created_at":"2024-02-17T15:36:28.610+08:00","updated_at":"2024-02-17T15:36:28.610+08:00"},{"id":15572040,"file_name":"1.png","project_id":695304,"asset_id":721182,"created_at":"2024-02-17T15:36:28.611+08:00","updated_at":"2024-02-17T15:36:28.611+08:00"},{"id":15572041,"file_name":"0.png","project_id":695304,"asset_id":721183,"created_at":"2024-02-17T15:36:28.612+08:00","updated_at":"2024-02-17T15:36:28.612+08:00"},{"id":15572042,"file_name":"2.png","project_id":695304,"asset_id":721184,"created_at":"2024-02-17T15:36:28.613+08:00","updated_at":"2024-02-17T15:36:28.613+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦