{"id":863581,"student_id":1981,"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\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\nrules.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 s.costume_id = 2\n items.append(s)\n \ni = 0\nwhile i \u003c 0:\n create_item(0, 0)\n i += 1\n\n# 遊戲迴圈\ndef loop():\n global clock, speed\n \n update_car() #農車動畫\n \n # 按下左右按鍵隱藏說明圖\n if key.left or key.right: rules.hidden = True\n \n # 如果說明圖尚未隱藏就跳過後面的程式\n if not rules.hidden: return\n \n clock += 1\n draw_text(str(clock // 60) + 'm', 30, 30, 'black', 50)\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\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 // 5) % 4\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-10-15T16:11:20.409+08:00","updated_at":"2024-10-15T16:11:20.409+08:00","name":"4_叩叮開農車_預設版 副本","language":"python","screenshot":{"url":null},"parent_id":829976,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"9ygsr9zrw","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18911752,"file_name":"c_3.png","project_id":863581,"asset_id":771555,"created_at":"2024-10-15T16:11:20.414+08:00","updated_at":"2024-10-15T16:11:20.414+08:00"},{"id":18911753,"file_name":"c_0.png","project_id":863581,"asset_id":771556,"created_at":"2024-10-15T16:11:20.415+08:00","updated_at":"2024-10-15T16:11:20.415+08:00"},{"id":18911754,"file_name":"c_7.png","project_id":863581,"asset_id":771557,"created_at":"2024-10-15T16:11:20.416+08:00","updated_at":"2024-10-15T16:11:20.416+08:00"},{"id":18911755,"file_name":"c_4.png","project_id":863581,"asset_id":771558,"created_at":"2024-10-15T16:11:20.417+08:00","updated_at":"2024-10-15T16:11:20.417+08:00"},{"id":18911756,"file_name":"c_5.png","project_id":863581,"asset_id":771559,"created_at":"2024-10-15T16:11:20.417+08:00","updated_at":"2024-10-15T16:11:20.417+08:00"},{"id":18911757,"file_name":"c_6.png","project_id":863581,"asset_id":771560,"created_at":"2024-10-15T16:11:20.418+08:00","updated_at":"2024-10-15T16:11:20.418+08:00"},{"id":18911758,"file_name":"c_11.png","project_id":863581,"asset_id":771561,"created_at":"2024-10-15T16:11:20.419+08:00","updated_at":"2024-10-15T16:11:20.419+08:00"},{"id":18911759,"file_name":"c_8.png","project_id":863581,"asset_id":771562,"created_at":"2024-10-15T16:11:20.420+08:00","updated_at":"2024-10-15T16:11:20.420+08:00"},{"id":18911760,"file_name":"b_0.png","project_id":863581,"asset_id":771563,"created_at":"2024-10-15T16:11:20.421+08:00","updated_at":"2024-10-15T16:11:20.421+08:00"},{"id":18911761,"file_name":"b_2.png","project_id":863581,"asset_id":771564,"created_at":"2024-10-15T16:11:20.422+08:00","updated_at":"2024-10-15T16:11:20.422+08:00"},{"id":18911762,"file_name":"gameover.png","project_id":863581,"asset_id":771565,"created_at":"2024-10-15T16:11:20.422+08:00","updated_at":"2024-10-15T16:11:20.422+08:00"},{"id":18911763,"file_name":"rules.png","project_id":863581,"asset_id":771566,"created_at":"2024-10-15T16:11:20.423+08:00","updated_at":"2024-10-15T16:11:20.423+08:00"},{"id":18911764,"file_name":"c_1.png","project_id":863581,"asset_id":771567,"created_at":"2024-10-15T16:11:20.424+08:00","updated_at":"2024-10-15T16:11:20.424+08:00"},{"id":18911765,"file_name":"c_2.png","project_id":863581,"asset_id":771568,"created_at":"2024-10-15T16:11:20.425+08:00","updated_at":"2024-10-15T16:11:20.425+08:00"},{"id":18911766,"file_name":"b_3.png","project_id":863581,"asset_id":771569,"created_at":"2024-10-15T16:11:20.426+08:00","updated_at":"2024-10-15T16:11:20.426+08:00"},{"id":18911767,"file_name":"b_4.png","project_id":863581,"asset_id":771570,"created_at":"2024-10-15T16:11:20.426+08:00","updated_at":"2024-10-15T16:11:20.426+08:00"},{"id":18911768,"file_name":"b_5.png","project_id":863581,"asset_id":771571,"created_at":"2024-10-15T16:11:20.427+08:00","updated_at":"2024-10-15T16:11:20.427+08:00"},{"id":18911769,"file_name":"b_6.png","project_id":863581,"asset_id":771572,"created_at":"2024-10-15T16:11:20.428+08:00","updated_at":"2024-10-15T16:11:20.428+08:00"},{"id":18911770,"file_name":"b_7.png","project_id":863581,"asset_id":771573,"created_at":"2024-10-15T16:11:20.429+08:00","updated_at":"2024-10-15T16:11:20.429+08:00"},{"id":18911771,"file_name":"b_1.png","project_id":863581,"asset_id":771574,"created_at":"2024-10-15T16:11:20.430+08:00","updated_at":"2024-10-15T16:11:20.430+08:00"},{"id":18911772,"file_name":"bg_2.png","project_id":863581,"asset_id":771575,"created_at":"2024-10-15T16:11:20.430+08:00","updated_at":"2024-10-15T16:11:20.430+08:00"},{"id":18911773,"file_name":"bg.png","project_id":863581,"asset_id":771576,"created_at":"2024-10-15T16:11:20.431+08:00","updated_at":"2024-10-15T16:11:20.431+08:00"},{"id":18911774,"file_name":"c_9.png","project_id":863581,"asset_id":771577,"created_at":"2024-10-15T16:11:20.432+08:00","updated_at":"2024-10-15T16:11:20.432+08:00"},{"id":18911775,"file_name":"c_10.png","project_id":863581,"asset_id":771578,"created_at":"2024-10-15T16:11:20.433+08:00","updated_at":"2024-10-15T16:11:20.433+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦