{"id":890316,"student_id":2589,"content":"from game import *\nfrom random import *\n\ncar_imgs = ['c_' + str(i) + '.png' for i in range(12)]\nitem_imgs = ['b_' + str(i) + '.png' for i in range(8)]\n\ncreate_sound('bgm.mp3', True)\nset_backdrop('bg_2.png')\ncar = create_sprite(car_imgs) #農車\ncar.y = 600\ncar.layer = 1\n# car.hidden = True\n\nrules = create_sprite('rules.png', 'gameover.png') #遊戲說明\nrules.layer = 2\n# rules.hidden = True\n\nspeed = 1.01 #速度\nspace = speed ** 20 #每排之間的大小比例\nreset = space ** 20 #重置時的大小比例\n\nitems = [] #存放所有移動物件的角色\nclock = 0\n\n# 創造角色\ndef create_item(x, y):\n s = create_sprite(item_imgs)\n s.scale = space ** y / 10\n s.x += x * s.scale * 600\n s.y = 270\n s.layer = s.scale\n if x == -5 or x == 5: s.costume_id = 2\n items.append(s)\n \ni = 0\nwhile i \u003c 11 * 20:\n create_item(i % 11 - 5, i // 11)\n i += 1\n\n# 遊戲迴圈\ndef loop():\n global clock, speed\n clock += 1\n \n update_car() #農車動畫\n \n # 按下左右按鍵隱藏說明圖\n if key.left or key.right:\n rules.hidden = True\n \n # 如果說明圖尚未隱藏就跳過後面的程式\n if not rules.hidden: return\n\n draw_text(str(clock // 60) + 'm', 30, 30, 'black', 50)\n \n i = 0\n while i \u003c len(items):\n update_item(items[i])\n i += 1\n \n speed = 1.01 + 0.01 * (clock / 3600)\n\n\n# 更新角色\ndef update_item(s):\n \n s.scale *= speed\n s.layer = s.scale\n s.x = (s.x - 600) * speed + 600\n \n # 當大小超過兩倍時就重置到遠方\n if s.scale \u003e 2:\n s.layer = -1\n s.scale /= reset\n s.x = (s.x - 600) / reset + 600\n if s.costume_id != 2: random_costume(s)\n \n # 如果不是稻草或柵欄\n if s.costume_id \u003e 1:\n # 如果在碰撞範圍內\n if s.x \u003e 350 and s.x \u003c 850 and s.scale \u003e 0.9 and s.scale \u003c= 1:\n rules.hidden = False\n rules.costume_id = 1\n stop()\n \n if key.left: s.x += s.scale * 15 * (1 + clock / 3600)\n if key.right: s.x -= s.scale * 15 * (1 + clock / 3600)\n\n\n#隨機切換造型\ndef random_costume(s):\n rand = random() #產生一個隨機 0 - 1 的隨機小數\n if rand \u003c 0.50: s.costume_id = 0 #稻草1\n elif rand \u003c 0.95: s.costume_id = 1 #稻草2\n elif rand \u003c 0.96: s.costume_id = 3 #石頭1\n elif rand \u003c 0.97: s.costume_id = 4 #石頭2\n elif rand \u003c 0.98: s.costume_id = 5 #稻草捲\n elif rand \u003c 0.99: s.costume_id = 6 #稻草人\n else: s.costume_id = 7 #乳牛\n \n#農車的動畫\ndef update_car():\n car.costume_id = (clock % 32) // 8\n if key.left: car.costume_id += 4\n elif key.right: car.costume_id += 8\n\nforever(loop) #重複執行遊戲迴圈\n\n\n\n","created_at":"2024-11-22T10:45:26.271+08:00","updated_at":"2024-11-22T10:45:44.785+08:00","name":"4_叩叮開農車_完整版","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":1,"hashid":"rdvsdr49p","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":34613659,"file_name":"c_3.png","project_id":890316,"asset_id":793517,"created_at":"2024-11-22T10:45:44.594+08:00","updated_at":"2024-11-22T10:45:44.594+08:00"},{"id":34613660,"file_name":"c_0.png","project_id":890316,"asset_id":793518,"created_at":"2024-11-22T10:45:44.599+08:00","updated_at":"2024-11-22T10:45:44.599+08:00"},{"id":34613661,"file_name":"c_7.png","project_id":890316,"asset_id":793519,"created_at":"2024-11-22T10:45:44.604+08:00","updated_at":"2024-11-22T10:45:44.604+08:00"},{"id":34613662,"file_name":"c_4.png","project_id":890316,"asset_id":793520,"created_at":"2024-11-22T10:45:44.608+08:00","updated_at":"2024-11-22T10:45:44.608+08:00"},{"id":34613663,"file_name":"c_5.png","project_id":890316,"asset_id":793521,"created_at":"2024-11-22T10:45:44.613+08:00","updated_at":"2024-11-22T10:45:44.613+08:00"},{"id":34613664,"file_name":"c_6.png","project_id":890316,"asset_id":793522,"created_at":"2024-11-22T10:45:44.619+08:00","updated_at":"2024-11-22T10:45:44.619+08:00"},{"id":34613665,"file_name":"c_11.png","project_id":890316,"asset_id":793523,"created_at":"2024-11-22T10:45:44.624+08:00","updated_at":"2024-11-22T10:45:44.624+08:00"},{"id":34613666,"file_name":"c_8.png","project_id":890316,"asset_id":793524,"created_at":"2024-11-22T10:45:44.628+08:00","updated_at":"2024-11-22T10:45:44.628+08:00"},{"id":34613667,"file_name":"b_0.png","project_id":890316,"asset_id":793525,"created_at":"2024-11-22T10:45:44.635+08:00","updated_at":"2024-11-22T10:45:44.635+08:00"},{"id":34613668,"file_name":"b_2.png","project_id":890316,"asset_id":793526,"created_at":"2024-11-22T10:45:44.640+08:00","updated_at":"2024-11-22T10:45:44.640+08:00"},{"id":34613669,"file_name":"gameover.png","project_id":890316,"asset_id":793527,"created_at":"2024-11-22T10:45:44.645+08:00","updated_at":"2024-11-22T10:45:44.645+08:00"},{"id":34613670,"file_name":"rules.png","project_id":890316,"asset_id":793528,"created_at":"2024-11-22T10:45:44.650+08:00","updated_at":"2024-11-22T10:45:44.650+08:00"},{"id":34613671,"file_name":"c_1.png","project_id":890316,"asset_id":793529,"created_at":"2024-11-22T10:45:44.655+08:00","updated_at":"2024-11-22T10:45:44.655+08:00"},{"id":34613672,"file_name":"c_2.png","project_id":890316,"asset_id":793530,"created_at":"2024-11-22T10:45:44.660+08:00","updated_at":"2024-11-22T10:45:44.660+08:00"},{"id":34613673,"file_name":"b_3.png","project_id":890316,"asset_id":793531,"created_at":"2024-11-22T10:45:44.667+08:00","updated_at":"2024-11-22T10:45:44.667+08:00"},{"id":34613674,"file_name":"b_4.png","project_id":890316,"asset_id":793532,"created_at":"2024-11-22T10:45:44.673+08:00","updated_at":"2024-11-22T10:45:44.673+08:00"},{"id":34613675,"file_name":"b_5.png","project_id":890316,"asset_id":793533,"created_at":"2024-11-22T10:45:44.678+08:00","updated_at":"2024-11-22T10:45:44.678+08:00"},{"id":34613676,"file_name":"b_6.png","project_id":890316,"asset_id":793534,"created_at":"2024-11-22T10:45:44.683+08:00","updated_at":"2024-11-22T10:45:44.683+08:00"},{"id":34613677,"file_name":"b_7.png","project_id":890316,"asset_id":793535,"created_at":"2024-11-22T10:45:44.690+08:00","updated_at":"2024-11-22T10:45:44.690+08:00"},{"id":34613678,"file_name":"b_1.png","project_id":890316,"asset_id":793536,"created_at":"2024-11-22T10:45:44.695+08:00","updated_at":"2024-11-22T10:45:44.695+08:00"},{"id":34613679,"file_name":"bg_2.png","project_id":890316,"asset_id":793537,"created_at":"2024-11-22T10:45:44.702+08:00","updated_at":"2024-11-22T10:45:44.702+08:00"},{"id":34613680,"file_name":"bg.png","project_id":890316,"asset_id":793538,"created_at":"2024-11-22T10:45:44.709+08:00","updated_at":"2024-11-22T10:45:44.709+08:00"},{"id":34613681,"file_name":"c_9.png","project_id":890316,"asset_id":793539,"created_at":"2024-11-22T10:45:44.714+08:00","updated_at":"2024-11-22T10:45:44.714+08:00"},{"id":34613682,"file_name":"c_10.png","project_id":890316,"asset_id":793540,"created_at":"2024-11-22T10:45:44.742+08:00","updated_at":"2024-11-22T10:45:44.742+08:00"},{"id":34613683,"file_name":"bgm.mp3","project_id":890316,"asset_id":793541,"created_at":"2024-11-22T10:45:44.783+08:00","updated_at":"2024-11-22T10:45:44.783+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦