{"id":725470,"student_id":10,"content":"from game import *\nfrom random import *\n\nset_backdrop(\"bg.png\")\ngrid = [[],[],[],[],[],[],[],[]]\nX = Y = None\nscore = 0\nimgs = [str(i) + '_0.png' for i in range(8)] + [str(i) + '_1.png' for i in range(8)]\n\nfor y in range(8):\n for x in range(8):\n b = create_sprite(imgs)\n b.costume_id = randint(0, 7)\n b.rotation_style = 'fixed'\n grid[x].append(b)\n\ntarget = create_sprite('target.png')\nlife = create_sprite('life.png')\ncreate_sprite('cover.png')\ninfo = create_sprite('rules.png', 'end.png')\n\ndef start_game():\n global score\n life.move_to(100, 450)\n life.y = 450 + 800\n info.hidden = True\n score = 0\n for row in grid:\n for b in row:\n b.costume_id = randint(0, 7)\n \ndef loop():\n global score\n if not info.hidden: return\n draw_text(score, 1024, 787, 'black', 40)\n life.y -= 0.5\n if life.y \u003c= 450:\n info.costume_id = 1\n info.hidden = False\n for x in range(8):\n for y in range(8):\n b = grid[x][y]\n tx = x * 100 + 220\n ty = y * 100 + 100\n if b.distance_to(tx, ty) \u003e= 15:\n b.toward(tx, ty)\n b.step_forward(15)\n else:\n b.move_to(tx, ty)\n if b.costume_id \u003e= 8:\n b.opacity -= 0.01\n if b.opacity \u003c= 0.5:\n b.opacity = 1\n b.costume_id = randint(0, 7)\n b.y = grid[x][0].y - 100\n grid[x].pop(y)\n grid[x] = [b] + grid[x]\n life.y += 100\n if life.y \u003e 1250: life.y = 1250\n score += 30\n target.hidden = X == None\n if X != None: target.move_to(grid[X][Y])\n check_grid()\n \ndef check_grid():\n for i in range(8):\n v = [row[i] for row in grid]\n h = grid[i]\n check_line(v)\n check_line(h)\n\ndef check_line(arr):\n count = 1\n for i in range(1, 9):\n if i \u003c 8 and arr[i].costume_id == arr[i - 1].costume_id and arr[i].costume_id \u003c 8:\n count += 1\n else:\n if count \u003e= 3:\n for c in range(i - count, i):\n arr[c].costume_id += 8\n count = 1\n \ndef click():\n global X, Y\n x = (cursor.x - 170) // 100\n y = (cursor.y - 50) // 100\n if not info.hidden: return\n if x \u003c 0 or y \u003c 0 or x \u003e 7 or y \u003e 7: return\n if X != None and abs(X - x) + abs(Y - y) == 1:\n swap(x, y, X, Y)\n X = None\n Y = None\n else:\n X = x\n Y = y\n\ndef swap(x1, y1, x2, y2):\n tmp = grid[x1][y1]\n grid[x1][y1] = grid[x2][y2]\n grid[x2][y2] = tmp\n\nforever(loop)\non('click', click)\ninfo.on('click', start_game)\n\n","created_at":"2024-04-01T10:21:13.869+08:00","updated_at":"2024-04-03T13:26:37.372+08:00","name":"動物管理員","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/725470/d67c45f767e4e282ba49728e6b9b3a3c.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":61,"hashid":"gk4snvmk8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":16219648,"file_name":"0_0.png","project_id":725470,"asset_id":732205,"created_at":"2024-04-01T10:27:30.972+08:00","updated_at":"2024-04-01T10:27:30.972+08:00"},{"id":16219649,"file_name":"0_1.png","project_id":725470,"asset_id":732206,"created_at":"2024-04-01T10:27:30.978+08:00","updated_at":"2024-04-01T10:27:30.978+08:00"},{"id":16219652,"file_name":"2_0.png","project_id":725470,"asset_id":732209,"created_at":"2024-04-01T10:27:31.877+08:00","updated_at":"2024-04-01T10:27:31.877+08:00"},{"id":16219653,"file_name":"2_1.png","project_id":725470,"asset_id":732210,"created_at":"2024-04-01T10:27:31.879+08:00","updated_at":"2024-04-01T10:27:31.879+08:00"},{"id":16219654,"file_name":"3_0.png","project_id":725470,"asset_id":732211,"created_at":"2024-04-01T10:27:32.322+08:00","updated_at":"2024-04-01T10:27:32.322+08:00"},{"id":16219655,"file_name":"3_1.png","project_id":725470,"asset_id":732212,"created_at":"2024-04-01T10:27:32.324+08:00","updated_at":"2024-04-01T10:27:32.324+08:00"},{"id":16219660,"file_name":"6_0.png","project_id":725470,"asset_id":732217,"created_at":"2024-04-01T10:27:33.609+08:00","updated_at":"2024-04-01T10:27:33.609+08:00"},{"id":16219661,"file_name":"6_1.png","project_id":725470,"asset_id":732218,"created_at":"2024-04-01T10:27:33.610+08:00","updated_at":"2024-04-01T10:27:33.610+08:00"},{"id":16219668,"file_name":"life.png","project_id":725470,"asset_id":732225,"created_at":"2024-04-01T11:11:10.944+08:00","updated_at":"2024-04-01T11:11:22.118+08:00"},{"id":16219666,"file_name":"end.png","project_id":725470,"asset_id":732223,"created_at":"2024-04-01T10:27:35.967+08:00","updated_at":"2024-04-01T10:27:35.967+08:00"},{"id":16219667,"file_name":"rules.png","project_id":725470,"asset_id":732224,"created_at":"2024-04-01T10:27:35.969+08:00","updated_at":"2024-04-01T10:27:35.969+08:00"},{"id":16219669,"file_name":"target.png","project_id":725470,"asset_id":728921,"created_at":"2024-04-01T12:02:30.554+08:00","updated_at":"2024-04-01T12:02:30.554+08:00"},{"id":16219664,"file_name":"bg.png","project_id":725470,"asset_id":732221,"created_at":"2024-04-01T10:27:34.716+08:00","updated_at":"2024-04-01T10:27:34.716+08:00"},{"id":16219665,"file_name":"cover.png","project_id":725470,"asset_id":732222,"created_at":"2024-04-01T10:27:34.718+08:00","updated_at":"2024-04-01T10:27:34.718+08:00"},{"id":16219658,"file_name":"5_0.png","project_id":725470,"asset_id":732215,"created_at":"2024-04-01T10:27:33.190+08:00","updated_at":"2024-04-01T10:27:33.190+08:00"},{"id":16219659,"file_name":"5_1.png","project_id":725470,"asset_id":732216,"created_at":"2024-04-01T10:27:33.193+08:00","updated_at":"2024-04-01T10:27:33.193+08:00"},{"id":16219656,"file_name":"4_0.png","project_id":725470,"asset_id":732213,"created_at":"2024-04-01T10:27:32.768+08:00","updated_at":"2024-04-01T10:27:32.768+08:00"},{"id":16219657,"file_name":"4_1.png","project_id":725470,"asset_id":732214,"created_at":"2024-04-01T10:27:32.771+08:00","updated_at":"2024-04-01T10:27:32.771+08:00"},{"id":16219662,"file_name":"7_0.png","project_id":725470,"asset_id":732219,"created_at":"2024-04-01T10:27:34.044+08:00","updated_at":"2024-04-01T10:27:34.044+08:00"},{"id":16219663,"file_name":"7_1.png","project_id":725470,"asset_id":732220,"created_at":"2024-04-01T10:27:34.046+08:00","updated_at":"2024-04-01T10:27:34.046+08:00"},{"id":16219650,"file_name":"1_0.png","project_id":725470,"asset_id":732207,"created_at":"2024-04-01T10:27:31.419+08:00","updated_at":"2024-04-01T10:27:31.419+08:00"},{"id":16219651,"file_name":"1_1.png","project_id":725470,"asset_id":732208,"created_at":"2024-04-01T10:27:31.423+08:00","updated_at":"2024-04-01T10:27:31.423+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦