{"id":1106913,"student_id":1488,"content":"from game import *\nfrom random import *\n\nbg = create_sprite('bg.png') #背景圖\nrules = create_sprite('rules.png') #遊戲規則\nresult = create_sprite(['end_' + str(i) + '.png' for i in range(13)]) #結果圖\nresult.hidden = True #預設隱藏\nrules.layer = result.layer = 1\ncreate_sound('bgm.mp3', True) #背景音樂\n\narr = [] #存放 16 個方塊角色\nimgs = [str(i) + '.png' for i in range(12)] #方塊角色的造型圖\n\nfor y in range(4):\n for x in range(4):\n b = create_sprite(imgs)\n b.x = 180 * x + 330\n b.y = 180 * y + 180\n arr.append(b)\n\ndef add():\n empty = []\n for b in arr:\n if b.costume_id == 0: empty.append(b)\n if len(empty) \u003e 0: #如果還有空的格子\n rand = randrange(len(empty)) #產生隨機數\n empty[rand].costume_id = randint(1, 2) #隨機挑選一個方塊設定造型\n empty[rand].scale = 0.1 #預設縮小\n else: #如果沒有空格子就結束遊戲\n gameover()\n create_sound('hit.mp3')\n \n idx = max([b.costume_id for b in arr])\n if idx \u003e result.costume_id:\n result.costume_id = idx\n create_sound('rise.mp3')\n\ndef loop():\n for b in arr + [bg]:\n if bg.x \u003e 600: b.x -= 5\n if bg.x \u003c 600: b.x += 5\n if bg.y \u003e 450: b.y -= 5\n if bg.y \u003c 450: b.y += 5\n if b.scale \u003c 1: b.scale += 0.05\n\n# 移動一行 4 個方塊\n# 由 a -\u003e b -\u003e c -\u003e d 方向移動\ndef move(a, b, c, d):\n \n # 如果 b 方塊為空,前一個方塊向右移動\n # if b.costume_id == 0:\n # b.costume_id = a.costume_id\n # a.costume_id = 0\n \n # 如果 c 方塊為空,前兩個方塊向右移動\n # if c.costume_id == 0:\n # c.costume_id = b.costume_id\n # b.costume_id = a.costume_id\n # a.costume_id = 0\n \n # 如果 d 方塊為空,前三個方塊向右移動\n \n \n \n # 如果 c、d 方塊一樣就合併,並讓 a、b 向右移動\n # if c.costume_id == d.costume_id and c.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 \n # 如果 b、c 方塊一樣就合併,並讓 a 向右移動\n # if b.costume_id == c.costume_id and b.costume_id != 0:\n # c.costume_id += 1\n # b.costume_id = a.costume_id\n # a.costume_id = 0\n \n # 如果 a、b 方塊一樣就合併\n \n\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 add()\n\n# 向左移動\ndef move_left():\n \n add()\n\n# 向上移動\ndef move_up():\n \n add()\n\n# 向下移動\ndef move_down():\n \n add()\n\n# 遊戲開始\ndef gamestart():\n rules.hidden = True\n\n# 遊戲結束\ndef gameover():\n result.hidden = False\n stop()\n\non('keydown', 'right', move_right) #向右移動\non('keydown', 'left', move_left) #向左移動\non('keydown', 'up', move_up) #向上移動\non('keydown', 'down', move_down) #向下移動\nrules.on('click', gamestart) #點擊遊戲說明開始遊戲\nforever(loop)\n\n","created_at":"2025-09-02T17:53:10.556+08:00","updated_at":"2025-09-02T17:53:10.556+08:00","name":"熱量大作戰(預設版) 副本","language":"python","screenshot":{"url":null},"parent_id":869728,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":27,"hashid":"d5msqpkwn","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":40921872,"file_name":"end_1.png","project_id":1106913,"asset_id":786358,"created_at":"2025-09-02T17:53:10.562+08:00","updated_at":"2025-09-02T17:53:10.562+08:00"},{"id":40921873,"file_name":"end_12.png","project_id":1106913,"asset_id":786359,"created_at":"2025-09-02T17:53:10.565+08:00","updated_at":"2025-09-02T17:53:10.565+08:00"},{"id":40921874,"file_name":"rules.png","project_id":1106913,"asset_id":786360,"created_at":"2025-09-02T17:53:10.566+08:00","updated_at":"2025-09-02T17:53:10.566+08:00"},{"id":40921875,"file_name":"12.png","project_id":1106913,"asset_id":786361,"created_at":"2025-09-02T17:53:10.567+08:00","updated_at":"2025-09-02T17:53:10.567+08:00"},{"id":40921876,"file_name":"2.png","project_id":1106913,"asset_id":786362,"created_at":"2025-09-02T17:53:10.568+08:00","updated_at":"2025-09-02T17:53:10.568+08:00"},{"id":40921877,"file_name":"3.png","project_id":1106913,"asset_id":786363,"created_at":"2025-09-02T17:53:10.569+08:00","updated_at":"2025-09-02T17:53:10.569+08:00"},{"id":40921878,"file_name":"end_6.png","project_id":1106913,"asset_id":786364,"created_at":"2025-09-02T17:53:10.570+08:00","updated_at":"2025-09-02T17:53:10.570+08:00"},{"id":40921879,"file_name":"end_7.png","project_id":1106913,"asset_id":786365,"created_at":"2025-09-02T17:53:10.571+08:00","updated_at":"2025-09-02T17:53:10.571+08:00"},{"id":40921880,"file_name":"0.png","project_id":1106913,"asset_id":786366,"created_at":"2025-09-02T17:53:10.572+08:00","updated_at":"2025-09-02T17:53:10.572+08:00"},{"id":40921881,"file_name":"1.png","project_id":1106913,"asset_id":786367,"created_at":"2025-09-02T17:53:10.573+08:00","updated_at":"2025-09-02T17:53:10.573+08:00"},{"id":40921882,"file_name":"10.png","project_id":1106913,"asset_id":786368,"created_at":"2025-09-02T17:53:10.574+08:00","updated_at":"2025-09-02T17:53:10.574+08:00"},{"id":40921883,"file_name":"11.png","project_id":1106913,"asset_id":786369,"created_at":"2025-09-02T17:53:10.575+08:00","updated_at":"2025-09-02T17:53:10.575+08:00"},{"id":40921884,"file_name":"bg.png","project_id":1106913,"asset_id":786370,"created_at":"2025-09-02T17:53:10.576+08:00","updated_at":"2025-09-02T17:53:10.576+08:00"},{"id":40921885,"file_name":"end_2.png","project_id":1106913,"asset_id":786371,"created_at":"2025-09-02T17:53:10.577+08:00","updated_at":"2025-09-02T17:53:10.577+08:00"},{"id":40921886,"file_name":"end_3.png","project_id":1106913,"asset_id":786372,"created_at":"2025-09-02T17:53:10.578+08:00","updated_at":"2025-09-02T17:53:10.578+08:00"},{"id":40921887,"file_name":"end_4.png","project_id":1106913,"asset_id":786373,"created_at":"2025-09-02T17:53:10.579+08:00","updated_at":"2025-09-02T17:53:10.579+08:00"},{"id":40921888,"file_name":"end_5.png","project_id":1106913,"asset_id":786374,"created_at":"2025-09-02T17:53:10.580+08:00","updated_at":"2025-09-02T17:53:10.580+08:00"},{"id":40921889,"file_name":"4.png","project_id":1106913,"asset_id":786375,"created_at":"2025-09-02T17:53:10.581+08:00","updated_at":"2025-09-02T17:53:10.581+08:00"},{"id":40921890,"file_name":"5.png","project_id":1106913,"asset_id":786376,"created_at":"2025-09-02T17:53:10.581+08:00","updated_at":"2025-09-02T17:53:10.581+08:00"},{"id":40921891,"file_name":"6.png","project_id":1106913,"asset_id":786377,"created_at":"2025-09-02T17:53:10.582+08:00","updated_at":"2025-09-02T17:53:10.582+08:00"},{"id":40921892,"file_name":"7.png","project_id":1106913,"asset_id":786378,"created_at":"2025-09-02T17:53:10.583+08:00","updated_at":"2025-09-02T17:53:10.583+08:00"},{"id":40921893,"file_name":"bgm.mp3","project_id":1106913,"asset_id":786379,"created_at":"2025-09-02T17:53:10.584+08:00","updated_at":"2025-09-02T17:53:10.584+08:00"},{"id":40921894,"file_name":"rise.mp3","project_id":1106913,"asset_id":786380,"created_at":"2025-09-02T17:53:10.585+08:00","updated_at":"2025-09-02T17:53:10.585+08:00"},{"id":40921895,"file_name":"end_10.png","project_id":1106913,"asset_id":786381,"created_at":"2025-09-02T17:53:10.586+08:00","updated_at":"2025-09-02T17:53:10.586+08:00"},{"id":40921896,"file_name":"end_11.png","project_id":1106913,"asset_id":786382,"created_at":"2025-09-02T17:53:10.587+08:00","updated_at":"2025-09-02T17:53:10.587+08:00"},{"id":40921897,"file_name":"end_8.png","project_id":1106913,"asset_id":786383,"created_at":"2025-09-02T17:53:10.588+08:00","updated_at":"2025-09-02T17:53:10.588+08:00"},{"id":40921898,"file_name":"end_9.png","project_id":1106913,"asset_id":786384,"created_at":"2025-09-02T17:53:10.589+08:00","updated_at":"2025-09-02T17:53:10.589+08:00"},{"id":40921899,"file_name":"hit.mp3","project_id":1106913,"asset_id":786385,"created_at":"2025-09-02T17:53:10.590+08:00","updated_at":"2025-09-02T17:53:10.590+08:00"},{"id":40921900,"file_name":"8.png","project_id":1106913,"asset_id":786386,"created_at":"2025-09-02T17:53:10.591+08:00","updated_at":"2025-09-02T17:53:10.591+08:00"},{"id":40921901,"file_name":"9.png","project_id":1106913,"asset_id":786387,"created_at":"2025-09-02T17:53:10.592+08:00","updated_at":"2025-09-02T17:53:10.592+08:00"},{"id":40921902,"file_name":"gameover.mp3","project_id":1106913,"asset_id":786388,"created_at":"2025-09-02T17:53:10.593+08:00","updated_at":"2025-09-02T17:53:10.593+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
繁中
简中
English
日本語
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦