{"id":694841,"student_id":10,"content":"from game import *\nfrom random import randint\n\ngrid = []\ncover = []\n\ndef onclick():\n x = cursor.x // 50\n y = cursor.y // 50\n if cover[x][y].hidden == True:\n open_round(x, y)\n else:\n open_block(x, y)\n\ndef flag(x, y):\n if cover[x][y].scale == 0.5:\n cover[x][y].scale = 1.0\n else:\n cover[x][y].scale = 0.5\n\ndef open_block(x, y):\n \n if x \u003c 0 or y \u003c 0 or x \u003e= 24 or y \u003e= 18: return\n if cover[x][y].hidden: return\n if cover[x][y].scale == 0.5: return\n \n cover[x][y].hidden = True\n \n if grid[x][y].costume_id == 0:\n open_round(x, y)\n \n if grid[x][y].costume_id == 9:\n gameover()\n\ndef open_round(x, y):\n for xx in range(-1, 2):\n for yy in range(-1, 2):\n open_block(x + xx, y + yy)\n\ndef count(x, y):\n c = 0\n for xx in range(-1, 2):\n for yy in range(-1, 2):\n X = x + xx\n Y = y + yy\n if X \u003c 0 or X \u003e= 24 or Y \u003c 0 or Y \u003e= 18:\n continue\n if grid[x + xx][y + yy].costume_id == 9:\n c += 1\n return c\n \n\ndef gameover():\n for x in range(24):\n for y in range(18):\n cover[x][y].hidden = True\n stop()\n \ndef gamewin():\n count = 0\n for x in range(24):\n for y in range(18):\n if cover[x][y].hidden == True:\n count += 1\n if count == 24 * 18 - 50:\n stop()\n\nfor x in range(24):\n grid.append([])\n cover.append([])\n for y in range(18):\n s = create_sprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', 'bomb.png')\n s.x = x * 50 + 25\n s.y = y * 50 + 25\n grid[x].append(s)\n \n s = create_sprite(\"g0.png\", \"g1.png\")\n s.x = x * 50 + 25\n s.y = y * 50 + 25\n s.costume_id = (x + y) % 2\n cover[x].append(s)\n \nfor i in range(50):\n x = randint(0, 23)\n y = randint(0, 17)\n grid[x][y].costume_id = 9\n \n\nfor x in range(24):\n for y in range(18):\n if grid[x][y].costume_id != 9:\n i = count(x, y)\n grid[x][y].costume_id = i\n \n\non('click', onclick)\non('keydown', 'space', flag)\n\n\ndef get_round(i):\n arr = []\n if (i \u003e= 24) arr.append(i - 23)\n if (i \u003e= 24) arr.append(i - 24)\n if (i \u003e= 24) arr.append(i - 25)\n if (i \u003e 432) arr.append(i + 23)\n if (i \u003e 432) arr.append(i + 24)\n if (i \u003e 432) arr.append(i + 25)\n if (i % 24 != 0) arr.append(i - 1)\n if (i % 24 != 23) arr.append(i + 1)\n return arr","created_at":"2024-02-14T10:18:25.414+08:00","updated_at":"2024-06-06T15:51:32.020+08:00","name":"踩地雷","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/694841/1a8751143ccad470d05353353d0c5c28.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":62,"hashid":"kdms8mzmp","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":15565041,"file_name":"bomb.png","project_id":694841,"asset_id":721043,"created_at":"2024-02-14T10:19:34.784+08:00","updated_at":"2024-02-14T10:19:34.784+08:00"},{"id":15565042,"file_name":"9.png","project_id":694841,"asset_id":721044,"created_at":"2024-02-14T10:19:34.786+08:00","updated_at":"2024-02-14T10:19:34.786+08:00"},{"id":15565045,"file_name":"6.png","project_id":694841,"asset_id":721047,"created_at":"2024-02-14T10:19:35.249+08:00","updated_at":"2024-02-14T10:19:35.249+08:00"},{"id":15565046,"file_name":"5.png","project_id":694841,"asset_id":721048,"created_at":"2024-02-14T10:19:35.250+08:00","updated_at":"2024-02-14T10:19:35.250+08:00"},{"id":15565043,"file_name":"8.png","project_id":694841,"asset_id":721045,"created_at":"2024-02-14T10:19:35.020+08:00","updated_at":"2024-02-14T10:19:35.020+08:00"},{"id":15565044,"file_name":"7.png","project_id":694841,"asset_id":721046,"created_at":"2024-02-14T10:19:35.022+08:00","updated_at":"2024-02-14T10:19:35.022+08:00"},{"id":15565039,"file_name":"0.png","project_id":694841,"asset_id":721041,"created_at":"2024-02-14T10:19:34.545+08:00","updated_at":"2024-02-14T10:19:34.545+08:00"},{"id":15565040,"file_name":"flag.png","project_id":694841,"asset_id":721042,"created_at":"2024-02-14T10:19:34.547+08:00","updated_at":"2024-02-14T10:19:34.547+08:00"},{"id":15565047,"file_name":"4.png","project_id":694841,"asset_id":721049,"created_at":"2024-02-14T10:19:35.479+08:00","updated_at":"2024-02-14T10:19:35.479+08:00"},{"id":15565048,"file_name":"3.png","project_id":694841,"asset_id":721050,"created_at":"2024-02-14T10:19:35.481+08:00","updated_at":"2024-02-14T10:19:35.481+08:00"},{"id":15565049,"file_name":"2.png","project_id":694841,"asset_id":721051,"created_at":"2024-02-14T10:19:35.708+08:00","updated_at":"2024-02-14T10:19:35.708+08:00"},{"id":15565050,"file_name":"1.png","project_id":694841,"asset_id":721052,"created_at":"2024-02-14T10:19:35.710+08:00","updated_at":"2024-02-14T10:19:35.710+08:00"},{"id":15565253,"file_name":"g1.png","project_id":694841,"asset_id":721083,"created_at":"2024-02-14T18:14:22.324+08:00","updated_at":"2024-02-14T18:14:22.324+08:00"},{"id":15565254,"file_name":"g0.png","project_id":694841,"asset_id":721084,"created_at":"2024-02-14T18:14:22.326+08:00","updated_at":"2024-02-14T18:14:22.326+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦