{"id":869322,"student_id":3760,"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') #按鈕\n# create_sound('bgm.wav', True) #背景音樂\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 \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) #不斷執行遊戲迴圈\n\n","created_at":"2024-10-23T17:16:00.076+08:00","updated_at":"2024-10-24T13:24:00.656+08:00","name":"懸崖勒叩叮_完整版","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/869322/daa15c271bd2036f03398eb9c0a86d29.jpg"},"parent_id":869321,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":11,"hashid":"36ysj4q5w","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":19022722,"file_name":"m.png","project_id":869322,"asset_id":786113,"created_at":"2024-10-23T17:16:10.347+08:00","updated_at":"2024-10-23T17:16:10.347+08:00"},{"id":19022723,"file_name":"n_0.png","project_id":869322,"asset_id":786114,"created_at":"2024-10-23T17:16:10.351+08:00","updated_at":"2024-10-23T17:16:10.351+08:00"},{"id":19022724,"file_name":"n_9.png","project_id":869322,"asset_id":786115,"created_at":"2024-10-23T17:16:10.355+08:00","updated_at":"2024-10-23T17:16:10.355+08:00"},{"id":19022725,"file_name":"p_2.png","project_id":869322,"asset_id":786116,"created_at":"2024-10-23T17:16:10.360+08:00","updated_at":"2024-10-23T17:16:10.360+08:00"},{"id":19022726,"file_name":"p_3.png","project_id":869322,"asset_id":786117,"created_at":"2024-10-23T17:16:10.364+08:00","updated_at":"2024-10-23T17:16:10.364+08:00"},{"id":19022727,"file_name":"rule.png","project_id":869322,"asset_id":786118,"created_at":"2024-10-23T17:16:10.370+08:00","updated_at":"2024-10-23T17:16:10.370+08:00"},{"id":19022728,"file_name":"n_5.png","project_id":869322,"asset_id":786119,"created_at":"2024-10-23T17:16:10.374+08:00","updated_at":"2024-10-23T17:16:10.374+08:00"},{"id":19022729,"file_name":"n_6.png","project_id":869322,"asset_id":786120,"created_at":"2024-10-23T17:16:10.377+08:00","updated_at":"2024-10-23T17:16:10.377+08:00"},{"id":19022730,"file_name":"r_6.png","project_id":869322,"asset_id":786121,"created_at":"2024-10-23T17:16:10.383+08:00","updated_at":"2024-10-23T17:16:10.383+08:00"},{"id":19022731,"file_name":"r_5.png","project_id":869322,"asset_id":786122,"created_at":"2024-10-23T17:16:10.388+08:00","updated_at":"2024-10-23T17:16:10.388+08:00"},{"id":19022732,"file_name":"n_1.png","project_id":869322,"asset_id":786123,"created_at":"2024-10-23T17:16:10.393+08:00","updated_at":"2024-10-23T17:16:10.393+08:00"},{"id":19022733,"file_name":"n_2.png","project_id":869322,"asset_id":786124,"created_at":"2024-10-23T17:16:10.397+08:00","updated_at":"2024-10-23T17:16:10.397+08:00"},{"id":19022734,"file_name":"r_8.png","project_id":869322,"asset_id":786125,"created_at":"2024-10-23T17:16:10.402+08:00","updated_at":"2024-10-23T17:16:10.402+08:00"},{"id":19022735,"file_name":"r_7.png","project_id":869322,"asset_id":786126,"created_at":"2024-10-23T17:16:10.408+08:00","updated_at":"2024-10-23T17:16:10.408+08:00"},{"id":19022736,"file_name":"r_4.png","project_id":869322,"asset_id":786127,"created_at":"2024-10-23T17:16:10.413+08:00","updated_at":"2024-10-23T17:16:10.413+08:00"},{"id":19022737,"file_name":"r_3.png","project_id":869322,"asset_id":786128,"created_at":"2024-10-23T17:16:10.418+08:00","updated_at":"2024-10-23T17:16:10.418+08:00"},{"id":19022738,"file_name":"bg.png","project_id":869322,"asset_id":786129,"created_at":"2024-10-23T17:16:10.423+08:00","updated_at":"2024-10-23T17:16:10.423+08:00"},{"id":19022739,"file_name":"g_0.png","project_id":869322,"asset_id":786130,"created_at":"2024-10-23T17:16:10.427+08:00","updated_at":"2024-10-23T17:16:10.427+08:00"},{"id":19022740,"file_name":"8.png","project_id":869322,"asset_id":786131,"created_at":"2024-10-23T17:16:10.431+08:00","updated_at":"2024-10-23T17:16:10.431+08:00"},{"id":19022741,"file_name":"9.png","project_id":869322,"asset_id":786132,"created_at":"2024-10-23T17:16:10.435+08:00","updated_at":"2024-10-23T17:16:10.435+08:00"},{"id":19022742,"file_name":"g_1.png","project_id":869322,"asset_id":786133,"created_at":"2024-10-23T17:16:10.439+08:00","updated_at":"2024-10-23T17:16:10.439+08:00"},{"id":19022743,"file_name":"r.png","project_id":869322,"asset_id":786134,"created_at":"2024-10-23T17:16:10.444+08:00","updated_at":"2024-10-23T17:16:10.444+08:00"},{"id":19022744,"file_name":"space.png","project_id":869322,"asset_id":786135,"created_at":"2024-10-23T17:16:10.461+08:00","updated_at":"2024-10-23T17:16:10.461+08:00"},{"id":19022745,"file_name":"n_3.png","project_id":869322,"asset_id":786136,"created_at":"2024-10-23T17:16:10.466+08:00","updated_at":"2024-10-23T17:16:10.466+08:00"},{"id":19022746,"file_name":"n_4.png","project_id":869322,"asset_id":786137,"created_at":"2024-10-23T17:16:10.470+08:00","updated_at":"2024-10-23T17:16:10.470+08:00"},{"id":19022747,"file_name":"r_2.png","project_id":869322,"asset_id":786138,"created_at":"2024-10-23T17:16:10.476+08:00","updated_at":"2024-10-23T17:16:10.476+08:00"},{"id":19022748,"file_name":"r_1.png","project_id":869322,"asset_id":786139,"created_at":"2024-10-23T17:16:10.487+08:00","updated_at":"2024-10-23T17:16:10.487+08:00"},{"id":19022749,"file_name":"r_0.png","project_id":869322,"asset_id":786140,"created_at":"2024-10-23T17:16:10.493+08:00","updated_at":"2024-10-23T17:16:10.493+08:00"},{"id":19022750,"file_name":"r_9.png","project_id":869322,"asset_id":786141,"created_at":"2024-10-23T17:16:10.499+08:00","updated_at":"2024-10-23T17:16:10.499+08:00"},{"id":19022751,"file_name":"n_7.png","project_id":869322,"asset_id":786142,"created_at":"2024-10-23T17:16:10.503+08:00","updated_at":"2024-10-23T17:16:10.503+08:00"},{"id":19022752,"file_name":"n_8.png","project_id":869322,"asset_id":786143,"created_at":"2024-10-23T17:16:10.508+08:00","updated_at":"2024-10-23T17:16:10.508+08:00"},{"id":19022753,"file_name":"0.png","project_id":869322,"asset_id":786144,"created_at":"2024-10-23T17:16:10.514+08:00","updated_at":"2024-10-23T17:16:10.514+08:00"},{"id":19022754,"file_name":"1.png","project_id":869322,"asset_id":786145,"created_at":"2024-10-23T17:16:10.518+08:00","updated_at":"2024-10-23T17:16:10.518+08:00"},{"id":19022755,"file_name":"tree.png","project_id":869322,"asset_id":786146,"created_at":"2024-10-23T17:16:10.523+08:00","updated_at":"2024-10-23T17:16:10.523+08:00"},{"id":19022756,"file_name":"p_0.png","project_id":869322,"asset_id":786147,"created_at":"2024-10-23T17:16:10.528+08:00","updated_at":"2024-10-23T17:16:10.528+08:00"},{"id":19022757,"file_name":"p_1.png","project_id":869322,"asset_id":786148,"created_at":"2024-10-23T17:16:10.533+08:00","updated_at":"2024-10-23T17:16:10.533+08:00"},{"id":19022758,"file_name":"brake.png","project_id":869322,"asset_id":786149,"created_at":"2024-10-23T17:16:10.537+08:00","updated_at":"2024-10-23T17:16:10.537+08:00"},{"id":19022759,"file_name":"10.png","project_id":869322,"asset_id":786150,"created_at":"2024-10-23T17:16:10.542+08:00","updated_at":"2024-10-23T17:16:10.542+08:00"},{"id":19022760,"file_name":"6.png","project_id":869322,"asset_id":786151,"created_at":"2024-10-23T17:16:10.547+08:00","updated_at":"2024-10-23T17:16:10.547+08:00"},{"id":19022761,"file_name":"7.png","project_id":869322,"asset_id":786152,"created_at":"2024-10-23T17:16:10.551+08:00","updated_at":"2024-10-23T17:16:10.551+08:00"},{"id":19022762,"file_name":"2.png","project_id":869322,"asset_id":786153,"created_at":"2024-10-23T17:16:10.555+08:00","updated_at":"2024-10-23T17:16:10.555+08:00"},{"id":19022763,"file_name":"3.png","project_id":869322,"asset_id":786154,"created_at":"2024-10-23T17:16:10.560+08:00","updated_at":"2024-10-23T17:16:10.560+08:00"},{"id":19022764,"file_name":"4.png","project_id":869322,"asset_id":786155,"created_at":"2024-10-23T17:16:10.564+08:00","updated_at":"2024-10-23T17:16:10.564+08:00"},{"id":19022765,"file_name":"5.png","project_id":869322,"asset_id":786156,"created_at":"2024-10-23T17:16:10.568+08:00","updated_at":"2024-10-23T17:16:10.568+08:00"},{"id":19022766,"file_name":"bgm.wav","project_id":869322,"asset_id":786157,"created_at":"2024-10-23T17:16:10.621+08:00","updated_at":"2024-10-23T17:16:10.621+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦