{"id":806903,"student_id":10,"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\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 # speed = 1.00\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-08-01T10:39:41.694+08:00","updated_at":"2024-08-27T14:08:17.312+08:00","name":"4_叩叮開農車_完整版","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/806903/e4639be367f46ffa29a36696d2160c51.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":44,"hashid":"5j3s8j3wg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18259920,"file_name":"c_3.png","project_id":806903,"asset_id":771170,"created_at":"2024-08-27T14:06:45.888+08:00","updated_at":"2024-08-27T14:06:45.888+08:00"},{"id":18259921,"file_name":"c_0.png","project_id":806903,"asset_id":771171,"created_at":"2024-08-27T14:06:45.893+08:00","updated_at":"2024-08-27T14:06:45.893+08:00"},{"id":18259922,"file_name":"c_7.png","project_id":806903,"asset_id":771172,"created_at":"2024-08-27T14:06:45.898+08:00","updated_at":"2024-08-27T14:06:45.898+08:00"},{"id":18259923,"file_name":"c_4.png","project_id":806903,"asset_id":771173,"created_at":"2024-08-27T14:06:45.902+08:00","updated_at":"2024-08-27T14:06:45.902+08:00"},{"id":18259924,"file_name":"c_5.png","project_id":806903,"asset_id":771174,"created_at":"2024-08-27T14:06:45.907+08:00","updated_at":"2024-08-27T14:06:45.907+08:00"},{"id":18259925,"file_name":"c_6.png","project_id":806903,"asset_id":771175,"created_at":"2024-08-27T14:06:45.912+08:00","updated_at":"2024-08-27T14:06:45.912+08:00"},{"id":18259926,"file_name":"c_11.png","project_id":806903,"asset_id":771176,"created_at":"2024-08-27T14:06:45.916+08:00","updated_at":"2024-08-27T14:06:45.916+08:00"},{"id":18259927,"file_name":"c_8.png","project_id":806903,"asset_id":771177,"created_at":"2024-08-27T14:06:45.920+08:00","updated_at":"2024-08-27T14:06:45.920+08:00"},{"id":18259928,"file_name":"b_0.png","project_id":806903,"asset_id":771178,"created_at":"2024-08-27T14:06:45.925+08:00","updated_at":"2024-08-27T14:06:45.925+08:00"},{"id":18259929,"file_name":"b_2.png","project_id":806903,"asset_id":771179,"created_at":"2024-08-27T14:06:45.929+08:00","updated_at":"2024-08-27T14:06:45.929+08:00"},{"id":18259930,"file_name":"gameover.png","project_id":806903,"asset_id":771180,"created_at":"2024-08-27T14:06:45.933+08:00","updated_at":"2024-08-27T14:06:45.933+08:00"},{"id":18259931,"file_name":"rules.png","project_id":806903,"asset_id":771181,"created_at":"2024-08-27T14:06:45.938+08:00","updated_at":"2024-08-27T14:06:45.938+08:00"},{"id":18259932,"file_name":"c_1.png","project_id":806903,"asset_id":771182,"created_at":"2024-08-27T14:06:45.942+08:00","updated_at":"2024-08-27T14:06:45.942+08:00"},{"id":18259933,"file_name":"c_2.png","project_id":806903,"asset_id":771183,"created_at":"2024-08-27T14:06:45.947+08:00","updated_at":"2024-08-27T14:06:45.947+08:00"},{"id":18259934,"file_name":"b_3.png","project_id":806903,"asset_id":771184,"created_at":"2024-08-27T14:06:45.955+08:00","updated_at":"2024-08-27T14:06:45.955+08:00"},{"id":18259935,"file_name":"b_4.png","project_id":806903,"asset_id":771185,"created_at":"2024-08-27T14:06:45.960+08:00","updated_at":"2024-08-27T14:06:45.960+08:00"},{"id":18259936,"file_name":"b_5.png","project_id":806903,"asset_id":771186,"created_at":"2024-08-27T14:06:45.965+08:00","updated_at":"2024-08-27T14:06:45.965+08:00"},{"id":18259937,"file_name":"b_6.png","project_id":806903,"asset_id":771187,"created_at":"2024-08-27T14:06:45.970+08:00","updated_at":"2024-08-27T14:06:45.970+08:00"},{"id":18259938,"file_name":"b_7.png","project_id":806903,"asset_id":771188,"created_at":"2024-08-27T14:06:45.975+08:00","updated_at":"2024-08-27T14:06:45.975+08:00"},{"id":18259939,"file_name":"b_1.png","project_id":806903,"asset_id":771189,"created_at":"2024-08-27T14:06:45.980+08:00","updated_at":"2024-08-27T14:06:45.980+08:00"},{"id":18259940,"file_name":"bg_2.png","project_id":806903,"asset_id":771190,"created_at":"2024-08-27T14:06:45.985+08:00","updated_at":"2024-08-27T14:06:45.985+08:00"},{"id":18259941,"file_name":"bg.png","project_id":806903,"asset_id":771191,"created_at":"2024-08-27T14:06:45.989+08:00","updated_at":"2024-08-27T14:06:45.989+08:00"},{"id":18259942,"file_name":"c_9.png","project_id":806903,"asset_id":771192,"created_at":"2024-08-27T14:06:45.993+08:00","updated_at":"2024-08-27T14:06:45.993+08:00"},{"id":18259943,"file_name":"c_10.png","project_id":806903,"asset_id":771193,"created_at":"2024-08-27T14:06:46.023+08:00","updated_at":"2024-08-27T14:06:46.023+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦