{"id":694873,"student_id":10,"content":"from game import *\nfrom random import randint\n\ngrid = []\narrows = []\nclickA = None\nclickB = None\n\npaths = []\n\nfor x in range(12):\n grid.append([])\n for y in range(9):\n s = create_sprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png')\n s.x = 100 * x + 50\n s.y = 100 * y + 50\n s.costume_id = y\n s.scale = 0.3\n grid[x].append(s)\n\nfor x in range(12):\n arrows.append([])\n for y in range(9):\n s = create_sprite('arrow.png')\n s.x = 100 * x + 50\n s.y = 100 * y + 50\n s.scale = 0.5\n arrows[x].append(s)\n\nfor i in range(100):\n x1 = randint(0, 11)\n y1 = randint(0, 8)\n x2 = randint(0, 11)\n y2 = randint(0, 8)\n tmp = grid[x1][y1].costume_id\n grid[x1][y1].costume_id = grid[x2][y2].costume_id\n grid[x2][y2].costume_id = tmp\n \ndef show_arrow(x, y):\n if x \u003e 0 and arrows[x - 1][y].hidden:\n arrows[x - 1][y].direction = 90\n arrows[x - 1][y].hidden = False\n if grid[x - 1][y].hidden: show_arrow(x - 1, y)\n if x \u003c 11 and arrows[x + 1][y].hidden:\n arrows[x + 1][y].direction = 270\n arrows[x + 1][y].hidden = False\n if grid[x + 1][y].hidden: show_arrow(x + 1, y)\n if y \u003e 0 and arrows[x][y - 1].hidden:\n arrows[x][y - 1].direction = 180\n arrows[x][y - 1].hidden = False\n if grid[x][y - 1].hidden: show_arrow(x, y - 1)\n if y \u003c 8 and arrows[x][y + 1].hidden:\n arrows[x][y + 1].direction = 0\n arrows[x][y + 1].hidden = False\n if grid[x][y + 1].hidden: show_arrow(x, y + 1)\n\n\ndef show_path(x, y):\n if arrows[x][y].hidden == False: return\n arrows[x][y].hidden = False\n if arrows[x][y].direction == 0: show_path(x, y - 1)\n if arrows[x][y].direction == 90: show_path(x + 1, y)\n if arrows[x][y].direction == 180: show_path(x, y + 1)\n if arrows[x][y].direction == 270: show_path(x - 1, y)\n \n\ndef hidden_all_arrows():\n for xx in range(12):\n for yy in range(9):\n arrows[xx][yy].hidden = True\n\ndef click():\n global clickA\n x = cursor.x // 100\n y = cursor.y // 100\n if clickA == None:\n clickA = grid[x][y]\n clickA.scale *= 0.5\n hidden_all_arrows()\n show_arrow(x, y)\n \n else:\n if clickA.costume_id == grid[x][y].costume_id and arrows[x][y].hidden == False:\n clickA.hidden = True\n grid[x][y].hidden = True\n hidden_all_arrows()\n show_path(x, y)\n else:\n clickA.scale *= 2\n clickA = None\n\non('click', click)","created_at":"2024-02-15T09:49:58.626+08:00","updated_at":"2024-03-21T12:09:20.086+08:00","name":"水果連連看","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/694873/49488994b0f803202932612959f1d46b.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":56,"hashid":"9ygs5eqjr","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":15565556,"file_name":"8.png","project_id":694873,"asset_id":721087,"created_at":"2024-02-15T09:50:30.317+08:00","updated_at":"2024-02-15T09:50:30.317+08:00"},{"id":15565557,"file_name":"7.png","project_id":694873,"asset_id":721088,"created_at":"2024-02-15T09:50:30.319+08:00","updated_at":"2024-02-15T09:50:30.319+08:00"},{"id":15565558,"file_name":"6.png","project_id":694873,"asset_id":721089,"created_at":"2024-02-15T09:50:30.681+08:00","updated_at":"2024-02-15T09:50:30.681+08:00"},{"id":15565559,"file_name":"5.png","project_id":694873,"asset_id":721090,"created_at":"2024-02-15T09:50:30.683+08:00","updated_at":"2024-02-15T09:50:30.683+08:00"},{"id":15565560,"file_name":"4.png","project_id":694873,"asset_id":721091,"created_at":"2024-02-15T09:50:31.040+08:00","updated_at":"2024-02-15T09:50:31.040+08:00"},{"id":15565561,"file_name":"3.png","project_id":694873,"asset_id":721092,"created_at":"2024-02-15T09:50:31.042+08:00","updated_at":"2024-02-15T09:50:31.042+08:00"},{"id":15565562,"file_name":"2.png","project_id":694873,"asset_id":721093,"created_at":"2024-02-15T09:50:31.399+08:00","updated_at":"2024-02-15T09:50:31.399+08:00"},{"id":15565563,"file_name":"1.png","project_id":694873,"asset_id":721094,"created_at":"2024-02-15T09:50:31.401+08:00","updated_at":"2024-02-15T09:50:31.401+08:00"},{"id":15565567,"file_name":"arrow.png","project_id":694873,"asset_id":721097,"created_at":"2024-02-15T10:18:07.888+08:00","updated_at":"2024-02-15T10:18:07.888+08:00"},{"id":15565564,"file_name":"0.png","project_id":694873,"asset_id":721095,"created_at":"2024-02-15T09:50:31.565+08:00","updated_at":"2024-02-15T09:50:31.565+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦