{"id":807275,"student_id":10,"content":"from game import *\nfrom random import *\n\nset_backdrop('bg.png') #設定背景\n\ngrounds = [] #儲存陸地\nsigns = [] #儲存牌子\ntrees = [] #儲存樹木\nspeed = 0 #速度\ndist = 0 #距離\n\nfor i in range(100):\n s = create_sprite('tree.png')\n s.x = 600 + i * 1200 * random() - 24000\n s.y = 650\n s.scale = random() * 0.8 + 0.2\n trees.append(s)\n\n# 創造 21 個陸地角色\nfor i in range(21):\n s = create_sprite('g_0.png', 'g_1.png')\n s.x = 600 + i * 1200 - 24000\n grounds.append(s)\n \nfor i in range(11):\n s = create_sprite(str(i) + '.png')\n s.x = 600 + i * 500 - 24000\n signs.append(s)\n\nbrake = create_sprite('brake.png') #煞車特效\nplayer = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png') #玩家叩叮\nn1 = create_sprite(['n_' + str(i) + '.png' for i in range(10)]) #十位數\nn2 = create_sprite(['n_' + str(i) + '.png' for i in range(10)]) #個位數\nnm = create_sprite('m.png') #單位\nresult = create_sprite(['r_' + str(i) + '.png' for i in range(10)]) #結果圖\nbtn = create_sprite('space.png', 'r.png')\nrules = create_sprite('rules.png')\n\nbrake.move_to(700, 630)\nn1.move_to(100, 100)\nn2.move_to(200, 100)\nnm.move_to(300, 100)\nresult.move_to(600, -450)\n\ngrounds[0].costume_id = 1\n\n# 遊戲迴圈\ndef loop():\n update_sprite() #移動角色\n update_speed() #更新速度\n update_score() #更新分數\n update_brake() #更新煞車特效\n update_result() #更新結果圖\n update_button() #更新按鈕\n if key.r: reset() #按下 R 重新開始\n \n#移動角色\ndef update_sprite():\n for s in grounds: s.x += speed\n for s in signs: s.x += speed\n for s in trees: s.x += speed\n \n#更新速度\ndef update_speed():\n global speed\n # 如果按下空白鍵而且叩叮沒有呈現煞車造型\n if key.space and player.costume_id != 3:\n speed += 1 #加速\n player.costume_id = (grounds[0].x // 300) % 2 + 1\n elif speed \u003e 0:\n speed -= 1 #減速\n player.costume_id = 3 #切換煞車造型\n \n # 如果超出懸崖就往下墜\n if player.x \u003c grounds[0].x:\n player.y += 30\n \n#更新分數\ndef update_score():\n global dist\n dist = (player.x - grounds[0].x) // 50 #計算與終點的距離\n hide = dist \u003c 0 or dist \u003e 100 #是否超出牌子的範圍\n n1.hidden = hide\n n2.hidden = hide\n nm.hidden = hide\n n1.costume_id = dist // 10 % 10 #十位數\n n2.costume_id = dist % 10 #個位數\n\n#更新煞車特效\ndef update_brake():\n brake.hidden = True\n # 如果正在移動 而且 是煞車狀態 而且 角色還沒有掉下去\n if speed \u003e 0 and player.costume_id == 3 and player.y == 450:\n brake.hidden = False #顯示煞車特效圖\n if dist % 2 == 0: brake.scale = 0.8\n if dist % 2 == 1: brake.scale = 1\n \n#更新結果圖\ndef update_result():\n # 速度停止 而且 是煞車狀態 而且 在牌子的範圍內\n if speed == 0 and player.costume_id == 3:\n dist = (player.x - grounds[0].x) // 50\n if dist \u003e= 0 and dist \u003c= 100 and result.y \u003c= 450:\n result.costume_id = 10 - dist // 10 #根據距離切換造型圖\n result.y += 5 #結果圖往下滑動\n \n#更新按鈕\ndef update_button():\n btn.hidden = speed \u003e 0 #如果正在加速或減速就隱藏\n #如果叩叮造型是 3 按鈕就切換重新開始的造型\n btn.costume_id = 1 if player.costume_id == 3 else 0\n \ndef hide_rules():\n rules.hidden = True\n \n#重新開始\ndef reset():\n global speed\n speed = 0\n player.y = 450\n player.costume_id = 0\n result.move_to(600, -450)\n diff = grounds[20].x - 600\n for s in grounds: s.x -= diff\n for s in signs: s.x -= diff\n for s in trees: s.x -= diff\n \nforever(loop) #不斷執行遊戲迴圈\nrules.on('click', hide_rules)\n\n","created_at":"2024-08-02T16:02:33.698+08:00","updated_at":"2024-08-05T14:33:28.281+08:00","name":"懸崖勒叩叮_完整版 (2)","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/807275/e9e8dc25c6b10246047217bc3f60f814.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":48,"hashid":"kdmsy884p","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":17938067,"file_name":"r_0.png","project_id":807275,"asset_id":762196,"created_at":"2024-08-05T14:34:08.113+08:00","updated_at":"2024-08-05T14:34:08.113+08:00"},{"id":17938066,"file_name":"r_9.png","project_id":807275,"asset_id":762187,"created_at":"2024-08-05T14:33:37.247+08:00","updated_at":"2024-08-05T14:33:37.247+08:00"},{"id":17938063,"file_name":"r_2.png","project_id":807275,"asset_id":762194,"created_at":"2024-08-05T14:33:36.509+08:00","updated_at":"2024-08-05T14:33:36.509+08:00"},{"id":17938064,"file_name":"r_1.png","project_id":807275,"asset_id":762195,"created_at":"2024-08-05T14:33:36.510+08:00","updated_at":"2024-08-05T14:33:36.510+08:00"},{"id":17938059,"file_name":"r_6.png","project_id":807275,"asset_id":762190,"created_at":"2024-08-05T14:33:34.122+08:00","updated_at":"2024-08-05T14:33:34.122+08:00"},{"id":17938060,"file_name":"r_5.png","project_id":807275,"asset_id":762191,"created_at":"2024-08-05T14:33:34.124+08:00","updated_at":"2024-08-05T14:33:34.124+08:00"},{"id":17938057,"file_name":"r_8.png","project_id":807275,"asset_id":762188,"created_at":"2024-08-05T14:33:32.918+08:00","updated_at":"2024-08-05T14:33:32.918+08:00"},{"id":17938058,"file_name":"r_7.png","project_id":807275,"asset_id":762189,"created_at":"2024-08-05T14:33:32.919+08:00","updated_at":"2024-08-05T14:33:32.919+08:00"},{"id":17938061,"file_name":"r_4.png","project_id":807275,"asset_id":762192,"created_at":"2024-08-05T14:33:35.829+08:00","updated_at":"2024-08-05T14:33:35.829+08:00"},{"id":17938062,"file_name":"r_3.png","project_id":807275,"asset_id":762193,"created_at":"2024-08-05T14:33:35.831+08:00","updated_at":"2024-08-05T14:33:35.831+08:00"},{"id":17937970,"file_name":"0.png","project_id":807275,"asset_id":762131,"created_at":"2024-08-05T14:01:32.249+08:00","updated_at":"2024-08-05T14:01:32.249+08:00"},{"id":17937971,"file_name":"1.png","project_id":807275,"asset_id":762132,"created_at":"2024-08-05T14:01:32.253+08:00","updated_at":"2024-08-05T14:01:32.253+08:00"},{"id":17937974,"file_name":"p_0.png","project_id":807275,"asset_id":762135,"created_at":"2024-08-05T14:01:32.268+08:00","updated_at":"2024-08-05T14:01:32.268+08:00"},{"id":17937975,"file_name":"p_1.png","project_id":807275,"asset_id":762136,"created_at":"2024-08-05T14:01:32.272+08:00","updated_at":"2024-08-05T14:01:32.272+08:00"},{"id":17937976,"file_name":"n_2.png","project_id":807275,"asset_id":762137,"created_at":"2024-08-05T14:01:32.276+08:00","updated_at":"2024-08-05T14:01:32.276+08:00"},{"id":17937977,"file_name":"n_3.png","project_id":807275,"asset_id":762138,"created_at":"2024-08-05T14:01:32.280+08:00","updated_at":"2024-08-05T14:01:32.280+08:00"},{"id":17937979,"file_name":"space.png","project_id":807275,"asset_id":762140,"created_at":"2024-08-05T14:01:32.289+08:00","updated_at":"2024-08-05T14:01:32.289+08:00"},{"id":17937980,"file_name":"tree.png","project_id":807275,"asset_id":762141,"created_at":"2024-08-05T14:01:32.293+08:00","updated_at":"2024-08-05T14:01:32.293+08:00"},{"id":17937981,"file_name":"6.png","project_id":807275,"asset_id":762142,"created_at":"2024-08-05T14:01:32.296+08:00","updated_at":"2024-08-05T14:01:32.296+08:00"},{"id":17937982,"file_name":"7.png","project_id":807275,"asset_id":762143,"created_at":"2024-08-05T14:01:32.300+08:00","updated_at":"2024-08-05T14:01:32.300+08:00"},{"id":17937983,"file_name":"8.png","project_id":807275,"asset_id":762144,"created_at":"2024-08-05T14:01:32.304+08:00","updated_at":"2024-08-05T14:01:32.304+08:00"},{"id":17937984,"file_name":"9.png","project_id":807275,"asset_id":762145,"created_at":"2024-08-05T14:01:32.310+08:00","updated_at":"2024-08-05T14:01:32.310+08:00"},{"id":17937985,"file_name":"m.png","project_id":807275,"asset_id":762146,"created_at":"2024-08-05T14:01:32.314+08:00","updated_at":"2024-08-05T14:01:32.314+08:00"},{"id":17937986,"file_name":"mountain.png","project_id":807275,"asset_id":762147,"created_at":"2024-08-05T14:01:32.318+08:00","updated_at":"2024-08-05T14:01:32.318+08:00"},{"id":17937987,"file_name":"p_2.png","project_id":807275,"asset_id":762148,"created_at":"2024-08-05T14:01:32.322+08:00","updated_at":"2024-08-05T14:01:32.322+08:00"},{"id":17937988,"file_name":"p_3.png","project_id":807275,"asset_id":762149,"created_at":"2024-08-05T14:01:32.326+08:00","updated_at":"2024-08-05T14:01:32.326+08:00"},{"id":17937989,"file_name":"4.png","project_id":807275,"asset_id":762150,"created_at":"2024-08-05T14:01:32.358+08:00","updated_at":"2024-08-05T14:01:32.358+08:00"},{"id":17937990,"file_name":"5.png","project_id":807275,"asset_id":762151,"created_at":"2024-08-05T14:01:32.363+08:00","updated_at":"2024-08-05T14:01:32.363+08:00"},{"id":17937991,"file_name":"2.png","project_id":807275,"asset_id":762152,"created_at":"2024-08-05T14:01:32.367+08:00","updated_at":"2024-08-05T14:01:32.367+08:00"},{"id":17937992,"file_name":"3.png","project_id":807275,"asset_id":762153,"created_at":"2024-08-05T14:01:32.372+08:00","updated_at":"2024-08-05T14:01:32.372+08:00"},{"id":17937995,"file_name":"10.png","project_id":807275,"asset_id":762156,"created_at":"2024-08-05T14:01:32.386+08:00","updated_at":"2024-08-05T14:01:32.386+08:00"},{"id":17937996,"file_name":"n_0.png","project_id":807275,"asset_id":762157,"created_at":"2024-08-05T14:01:32.391+08:00","updated_at":"2024-08-05T14:01:32.391+08:00"},{"id":17937997,"file_name":"n_1.png","project_id":807275,"asset_id":762158,"created_at":"2024-08-05T14:01:32.395+08:00","updated_at":"2024-08-05T14:01:32.395+08:00"},{"id":17938000,"file_name":"n_4.png","project_id":807275,"asset_id":762161,"created_at":"2024-08-05T14:01:32.409+08:00","updated_at":"2024-08-05T14:01:32.409+08:00"},{"id":17938001,"file_name":"n_5.png","project_id":807275,"asset_id":762162,"created_at":"2024-08-05T14:01:32.413+08:00","updated_at":"2024-08-05T14:01:32.413+08:00"},{"id":17938002,"file_name":"g_0.png","project_id":807275,"asset_id":762163,"created_at":"2024-08-05T14:01:32.418+08:00","updated_at":"2024-08-05T14:01:32.418+08:00"},{"id":17938003,"file_name":"g_1.png","project_id":807275,"asset_id":762164,"created_at":"2024-08-05T14:01:32.422+08:00","updated_at":"2024-08-05T14:01:32.422+08:00"},{"id":17938004,"file_name":"n_6.png","project_id":807275,"asset_id":762165,"created_at":"2024-08-05T14:01:32.426+08:00","updated_at":"2024-08-05T14:01:32.426+08:00"},{"id":17938005,"file_name":"n_7.png","project_id":807275,"asset_id":762166,"created_at":"2024-08-05T14:01:32.430+08:00","updated_at":"2024-08-05T14:01:32.430+08:00"},{"id":17938006,"file_name":"n_8.png","project_id":807275,"asset_id":762167,"created_at":"2024-08-05T14:01:32.434+08:00","updated_at":"2024-08-05T14:01:32.434+08:00"},{"id":17938007,"file_name":"n_9.png","project_id":807275,"asset_id":762168,"created_at":"2024-08-05T14:01:32.439+08:00","updated_at":"2024-08-05T14:01:32.439+08:00"},{"id":17938008,"file_name":"bg.png","project_id":807275,"asset_id":762169,"created_at":"2024-08-05T14:01:32.443+08:00","updated_at":"2024-08-05T14:01:32.443+08:00"},{"id":17938009,"file_name":"brake.png","project_id":807275,"asset_id":762170,"created_at":"2024-08-05T14:01:32.447+08:00","updated_at":"2024-08-05T14:01:32.447+08:00"},{"id":17938010,"file_name":"r.png","project_id":807275,"asset_id":762171,"created_at":"2024-08-05T14:01:32.452+08:00","updated_at":"2024-08-05T14:01:32.452+08:00"},{"id":17938036,"file_name":"rules.png","project_id":807275,"asset_id":762197,"created_at":"2024-08-05T14:21:58.719+08:00","updated_at":"2024-08-05T14:21:58.719+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦