{"id":694661,"student_id":10,"content":"from game import *\nfrom random import randint\n\nset_backdrop('bg.png')\n\nbgm = create_sound('bgm.mp3')\n\nscore = [0, 0, 0, 0, 0, 0, 0, 0]\ngrid = [[],[],[],[],[],[],[],[]]\nX = None\nY = None\n\nline = create_sprite('line.png')\nline.move_to(100, 450)\n\nfor y in range(8):\n for x in range(8):\n b = create_sprite('0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png')\n b.costume_id = randint(0, 7)\n b.scale = 0.9\n b.rotation_style = 'fixed'\n grid[x].append(b)\n\ncreate_sprite('cover.png')\n\nfor i in range(8):\n s = create_sprite(str(i) + '.png')\n s.move_to(1060, 100 + i * 50)\n s.scale = 0.3\n\ntarget = create_sprite('target.png')\n\ndef startgame():\n info.hidden = True\n line.y = 450\n \ninfo = create_sprite('info.png', 'end.png')\n\ndef loop():\n \n if info.hidden:\n total = 0\n for i in range(8):\n draw_text('x ' + str(score[i]), 1090, 85 + i * 50, 'black', 30)\n total += score[i]\n draw_text(total, 1050, 782, 'black', 50)\n \n if info.hidden: line.y += 0.5\n \n if line.y \u003e 450 + 800:\n info.costume_id = 1\n info.hidden = False\n stop()\n \n check_grid()\n for x in range(8):\n for y in range(8):\n b = grid[x][y]\n tx = x * 100 + 250\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 \n if b.opacity \u003c 1:\n b.opacity -= 0.03\n \n if b.opacity \u003c= 0:\n score[b.costume_id] += 1\n b.costume_id = randint(0, 7)\n b.opacity = 1\n b.y = grid[x][0].y - 100\n grid[x].pop(y)\n grid[x] = [b] + grid[x]\n line.y = 450\n\n target.hidden = X == None\n if X != None: target.move_to(grid[X][Y])\n \ndef check_grid():\n flag = False\n for i in range(8):\n v = [row[i] for row in grid]\n h = grid[i]\n if check_line(v): flag = True\n if check_line(h): flag = True\n return flag\n\ndef check_line(arr):\n flag = False\n count = 1\n for idx in range(1, 9):\n if idx \u003c 8 and arr[idx].costume_id == arr[idx - 1].costume_id and arr[idx].opacity == 1:\n count += 1\n else:\n if count \u003e= 3:\n for c in range(idx - count, idx):\n arr[c].opacity = 0.5\n flag = True\n count = 1\n \n if flag: create_sound('coin.mp3')\n return flag\n\ndef click():\n global X, Y\n if not info.hidden: return\n x = (cursor.x - 200) // 100\n y = (cursor.y - 50) // 100\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 if check_grid() == False: 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', startgame)\n\n","created_at":"2024-02-08T20:59:58.389+08:00","updated_at":"2024-04-01T11:19:44.648+08:00","name":"zoo keeper","language":"python","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/694661/a4771b0e4ccdf8e4c189026d4893253a.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":62,"hashid":"jzms93yzk","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":16021752,"file_name":"target.png","project_id":694661,"asset_id":728921,"created_at":"2024-03-19T16:40:02.237+08:00","updated_at":"2024-03-19T16:40:02.237+08:00"},{"id":16021744,"file_name":"6.png","project_id":694661,"asset_id":728918,"created_at":"2024-03-19T16:35:34.377+08:00","updated_at":"2024-03-19T16:35:34.377+08:00"},{"id":16021745,"file_name":"7.png","project_id":694661,"asset_id":728919,"created_at":"2024-03-19T16:35:34.379+08:00","updated_at":"2024-03-19T16:35:34.379+08:00"},{"id":16021740,"file_name":"2.png","project_id":694661,"asset_id":728914,"created_at":"2024-03-19T16:35:33.563+08:00","updated_at":"2024-03-19T16:35:33.563+08:00"},{"id":16021741,"file_name":"3.png","project_id":694661,"asset_id":728915,"created_at":"2024-03-19T16:35:33.565+08:00","updated_at":"2024-03-19T16:35:33.565+08:00"},{"id":16021738,"file_name":"0.png","project_id":694661,"asset_id":728912,"created_at":"2024-03-19T16:35:33.143+08:00","updated_at":"2024-03-19T16:35:33.143+08:00"},{"id":16021739,"file_name":"1.png","project_id":694661,"asset_id":728913,"created_at":"2024-03-19T16:35:33.145+08:00","updated_at":"2024-03-19T16:35:33.145+08:00"},{"id":16021742,"file_name":"4.png","project_id":694661,"asset_id":728916,"created_at":"2024-03-19T16:35:33.975+08:00","updated_at":"2024-03-19T16:35:33.975+08:00"},{"id":16021743,"file_name":"5.png","project_id":694661,"asset_id":728917,"created_at":"2024-03-19T16:35:33.976+08:00","updated_at":"2024-03-19T16:35:33.976+08:00"},{"id":16031240,"file_name":"bgm.mp3","project_id":694661,"asset_id":729108,"created_at":"2024-03-22T15:23:07.722+08:00","updated_at":"2024-03-22T15:23:07.722+08:00"},{"id":16031238,"file_name":"info.png","project_id":694661,"asset_id":729106,"created_at":"2024-03-22T15:05:49.124+08:00","updated_at":"2024-03-22T15:05:49.124+08:00"},{"id":16031232,"file_name":"cover.png","project_id":694661,"asset_id":729100,"created_at":"2024-03-22T14:30:03.760+08:00","updated_at":"2024-03-22T14:30:03.760+08:00"},{"id":16031241,"file_name":"coin.mp3","project_id":694661,"asset_id":729109,"created_at":"2024-03-22T15:27:29.112+08:00","updated_at":"2024-03-22T15:27:29.112+08:00"},{"id":16031235,"file_name":"line.png","project_id":694661,"asset_id":729103,"created_at":"2024-03-22T14:41:36.337+08:00","updated_at":"2024-03-22T14:41:36.337+08:00"},{"id":16031236,"file_name":"end.png","project_id":694661,"asset_id":729104,"created_at":"2024-03-22T14:57:00.665+08:00","updated_at":"2024-03-22T14:57:00.665+08:00"},{"id":16031233,"file_name":"bg.png","project_id":694661,"asset_id":729101,"created_at":"2024-03-22T14:31:11.152+08:00","updated_at":"2024-03-22T14:31:11.152+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦