{"id":735732,"student_id":10,"content":"from game import *\nfrom random import randint\n\narr = []\ntotal = 0\nlevel = 1\nbg = create_sprite(\"bg.png\")\nbg.xx = 600\nbg.yy = 450\n\ncreate_sound('bgm.mp3', True)\n\nfor y in range(4):\n for x in range(4):\n b = create_sprite([str(i) + '.png' for i in range(12)])\n b.x = b.xx = 200 * x + 300\n b.y = b.yy = 200 * y + 150\n b.scale = 0.1\n arr.append(b)\n\ninfo = create_sprite([\"rules.png\"] + [f\"end_{i}.png\" for i in range(1, 13)])\n\ndef loop():\n for b in arr + [bg]:\n if b.x \u003e b.xx: b.x -= 10\n if b.x \u003c b.xx: b.x += 10\n if b.y \u003e b.yy: b.y -= 10\n if b.y \u003c b.yy: b.y += 10\n if b.scale \u003e= 1.04: b.scale -= 0.04\n elif b.scale \u003c= 0.96: b.scale += 0.04\n \n if info.costume_id != 0 and not info.hidden:\n draw_text('' + str(total) + ' 大卡', 620, 700, 'red', 50)\n\ndef start_game():\n for b in arr: b.costume_id = 0\n for i in range(2): add()\n info.hidden = True\n\ndef add():\n global total\n empty = []\n for b in arr:\n if b.costume_id == 0:\n empty.append(b)\n if len(empty) == 0:\n gameover()\n else:\n rand = randint(0, len(empty) - 1)\n empty[rand].costume_id = randint(1, 2)\n empty[rand].scale = 0.1\n total += empty[rand].costume_id\n \n create_sound('hit.mp3')\n \n idx = max([i.costume_id for i in arr]) + 1\n if idx \u003e info.costume_id:\n info.costume_id = idx - 1\n create_sound('rise.mp3')\n \ndef move(a, b, c, d):\n if d.costume_id == 0:\n d.costume_id = c.costume_id\n c.costume_id = 0\n if c.costume_id == 0:\n c.costume_id = b.costume_id\n b.costume_id = 0\n if b.costume_id == 0:\n b.costume_id = a.costume_id\n a.costume_id = 0\n if d.costume_id == 0:\n d.costume_id = c.costume_id\n c.costume_id = 0\n if c.costume_id == 0:\n c.costume_id = b.costume_id\n b.costume_id = 0\n if d.costume_id == 0:\n d.costume_id = c.costume_id\n c.costume_id = 0\n if d.costume_id == c.costume_id and d.costume_id != 0:\n d.costume_id += 1\n c.costume_id = b.costume_id\n b.costume_id = a.costume_id\n a.costume_id = 0\n d.scale = 1.3\n if c.costume_id == b.costume_id and c.costume_id != 0:\n c.costume_id += 1\n b.costume_id = a.costume_id\n a.costume_id = 0\n c.scale = 1.3\n if b.costume_id == a.costume_id and b.costume_id != 0:\n b.costume_id += 1\n a.costume_id = 0\n b.scale = 1.3\n\ndef move_right():\n move(arr[0], arr[1], arr[2], arr[3])\n move(arr[4], arr[5], arr[6], arr[7])\n move(arr[8], arr[9], arr[10], arr[11])\n move(arr[12], arr[13], arr[14], arr[15])\n for b in arr: b.x += 20\n bg.x += 20\n add()\n\ndef move_left():\n move(arr[3], arr[2], arr[1], arr[0])\n move(arr[7], arr[6], arr[5], arr[4])\n move(arr[11], arr[10], arr[9], arr[8])\n move(arr[15], arr[14], arr[13], arr[12])\n for b in arr: b.x -= 20\n bg.x -= 20\n add()\n \ndef move_up():\n move(arr[12], arr[8], arr[4], arr[0])\n move(arr[13], arr[9], arr[5], arr[1])\n move(arr[14], arr[10], arr[6], arr[2])\n move(arr[15], arr[11], arr[7], arr[3])\n for b in arr: b.y -= 20\n bg.y -= 20\n add()\n \ndef move_down():\n move(arr[0], arr[4], arr[8], arr[12])\n move(arr[1], arr[5], arr[9], arr[13])\n move(arr[2], arr[6], arr[10], arr[14])\n move(arr[3], arr[7], arr[11], arr[15])\n for b in arr: b.y += 20\n bg.y += 20\n add()\n\ndef gameover():\n info.hidden = False\n stop()\n create_sound('gameover.mp3')\n\non('keydown', 'right', move_right)\non('keydown', 'left', move_left)\non('keydown', 'up', move_up)\non('keydown', 'down', move_down)\ninfo.on('click', start_game)\nforever(loop)\n","created_at":"2024-04-23T17:11:36.547+08:00","updated_at":"2024-05-22T10:55:04.243+08:00","name":"營養大作戰","language":"python","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/735732/47a03f451fdfd4cc5988431dc2b43b01.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":151,"hashid":"p93sr2qzg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":16439699,"file_name":"win.wav","project_id":735732,"asset_id":735952,"created_at":"2024-04-23T17:52:47.033+08:00","updated_at":"2024-04-23T17:52:47.033+08:00"},{"id":16439701,"file_name":"bgm.mp3","project_id":735732,"asset_id":735954,"created_at":"2024-04-23T18:12:26.582+08:00","updated_at":"2024-04-23T18:12:26.582+08:00"},{"id":16439700,"file_name":"rise.mp3","project_id":735732,"asset_id":735953,"created_at":"2024-04-23T17:55:49.637+08:00","updated_at":"2024-04-23T17:55:49.637+08:00"},{"id":16439697,"file_name":"hit.mp3","project_id":735732,"asset_id":735950,"created_at":"2024-04-23T17:47:03.799+08:00","updated_at":"2024-04-23T17:47:03.799+08:00"},{"id":16439698,"file_name":"gameover.mp3","project_id":735732,"asset_id":735951,"created_at":"2024-04-23T17:48:19.724+08:00","updated_at":"2024-04-23T17:48:19.724+08:00"},{"id":16449795,"file_name":"end_5.png","project_id":735732,"asset_id":736777,"created_at":"2024-04-26T14:36:28.940+08:00","updated_at":"2024-04-26T14:36:28.940+08:00"},{"id":16449796,"file_name":"end_6.png","project_id":735732,"asset_id":736778,"created_at":"2024-04-26T14:36:28.942+08:00","updated_at":"2024-04-26T14:36:28.942+08:00"},{"id":16449799,"file_name":"end_9.png","project_id":735732,"asset_id":736781,"created_at":"2024-04-26T14:36:32.192+08:00","updated_at":"2024-04-26T14:36:32.192+08:00"},{"id":16449800,"file_name":"end_10.png","project_id":735732,"asset_id":736782,"created_at":"2024-04-26T14:36:32.193+08:00","updated_at":"2024-04-26T14:36:32.193+08:00"},{"id":16449781,"file_name":"4.png","project_id":735732,"asset_id":736763,"created_at":"2024-04-26T14:36:19.927+08:00","updated_at":"2024-04-26T14:36:19.927+08:00"},{"id":16449782,"file_name":"5.png","project_id":735732,"asset_id":736764,"created_at":"2024-04-26T14:36:19.929+08:00","updated_at":"2024-04-26T14:36:19.929+08:00"},{"id":16449785,"file_name":"8.png","project_id":735732,"asset_id":736767,"created_at":"2024-04-26T14:36:21.293+08:00","updated_at":"2024-04-26T14:36:21.293+08:00"},{"id":16449786,"file_name":"9.png","project_id":735732,"asset_id":736768,"created_at":"2024-04-26T14:36:21.295+08:00","updated_at":"2024-04-26T14:36:21.295+08:00"},{"id":16449787,"file_name":"10.png","project_id":735732,"asset_id":736769,"created_at":"2024-04-26T14:36:22.193+08:00","updated_at":"2024-04-26T14:36:22.193+08:00"},{"id":16449788,"file_name":"11.png","project_id":735732,"asset_id":736770,"created_at":"2024-04-26T14:36:22.195+08:00","updated_at":"2024-04-26T14:36:22.195+08:00"},{"id":16449791,"file_name":"end_1.png","project_id":735732,"asset_id":736773,"created_at":"2024-04-26T14:36:23.936+08:00","updated_at":"2024-04-26T14:36:23.936+08:00"},{"id":16449792,"file_name":"end_2.png","project_id":735732,"asset_id":736774,"created_at":"2024-04-26T14:36:23.938+08:00","updated_at":"2024-04-26T14:36:23.938+08:00"},{"id":16449793,"file_name":"end_3.png","project_id":735732,"asset_id":736775,"created_at":"2024-04-26T14:36:26.349+08:00","updated_at":"2024-04-26T14:36:26.349+08:00"},{"id":16449794,"file_name":"end_4.png","project_id":735732,"asset_id":736776,"created_at":"2024-04-26T14:36:26.351+08:00","updated_at":"2024-04-26T14:36:26.351+08:00"},{"id":16449779,"file_name":"2.png","project_id":735732,"asset_id":736761,"created_at":"2024-04-26T14:36:19.462+08:00","updated_at":"2024-04-26T14:36:19.462+08:00"},{"id":16449780,"file_name":"3.png","project_id":735732,"asset_id":736762,"created_at":"2024-04-26T14:36:19.463+08:00","updated_at":"2024-04-26T14:36:19.463+08:00"},{"id":16449803,"file_name":"rules.png","project_id":735732,"asset_id":736785,"created_at":"2024-04-26T14:36:33.799+08:00","updated_at":"2024-04-26T14:36:33.799+08:00"},{"id":16449789,"file_name":"12.png","project_id":735732,"asset_id":736771,"created_at":"2024-04-26T14:36:22.764+08:00","updated_at":"2024-04-26T14:36:22.764+08:00"},{"id":16449790,"file_name":"bg.png","project_id":735732,"asset_id":736772,"created_at":"2024-04-26T14:36:22.766+08:00","updated_at":"2024-04-26T14:36:22.766+08:00"},{"id":16449783,"file_name":"6.png","project_id":735732,"asset_id":736765,"created_at":"2024-04-26T14:36:20.801+08:00","updated_at":"2024-04-26T14:36:20.801+08:00"},{"id":16449784,"file_name":"7.png","project_id":735732,"asset_id":736766,"created_at":"2024-04-26T14:36:20.803+08:00","updated_at":"2024-04-26T14:36:20.803+08:00"},{"id":16449797,"file_name":"end_7.png","project_id":735732,"asset_id":736779,"created_at":"2024-04-26T14:36:30.244+08:00","updated_at":"2024-04-26T14:36:30.244+08:00"},{"id":16449798,"file_name":"end_8.png","project_id":735732,"asset_id":736780,"created_at":"2024-04-26T14:36:30.246+08:00","updated_at":"2024-04-26T14:36:30.246+08:00"},{"id":16449801,"file_name":"end_11.png","project_id":735732,"asset_id":736783,"created_at":"2024-04-26T14:36:33.125+08:00","updated_at":"2024-04-26T14:36:33.125+08:00"},{"id":16449802,"file_name":"end_12.png","project_id":735732,"asset_id":736784,"created_at":"2024-04-26T14:36:33.127+08:00","updated_at":"2024-04-26T14:36:33.127+08:00"},{"id":16449777,"file_name":"0.png","project_id":735732,"asset_id":735920,"created_at":"2024-04-26T14:36:18.962+08:00","updated_at":"2024-04-26T14:36:18.962+08:00"},{"id":16449778,"file_name":"1.png","project_id":735732,"asset_id":736760,"created_at":"2024-04-26T14:36:18.965+08:00","updated_at":"2024-04-26T14:36:18.965+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦