{"id":782382,"student_id":10,"content":"from game import *\nfrom random import *\n\nset_backdrop('bg.png')\n\ngrounds = [] #儲存陸地\nsigns = [] #儲存牌子\ntrees = [] #儲存樹木\nspeed = 0 #速度\ndist = 0 #距離\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\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)]) #結果圖\nspace = create_sprite('space.png') #空白鍵\nreset_btn = create_sprite('r.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)\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 if key.r: reset() #按下 R 重新開始\n \n#移動角色\ndef update_sprite():\n for s in grounds: 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 space.hidden = True\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 == 2 and dist \u003e= 0 and dist \u003c= 100:\n reset_btn.hidden = False #顯示結果圖\n result.y += 10 #結果圖往下滑動\n result.costume_id = 10 - dist // 10 #根據距離切換造型圖\n \n#重新開始\ndef reset():\n player.y = 450\n player.costume_id = 0\n result.move_to(600, -450)\n space.hidden = False\n reset_btn.hidden = True\n diff = grounds[20].x - 600\n for s in grounds: s.x -= diff\n \nforever(loop) #不斷執行遊戲迴圈\n\n","created_at":"2024-07-03T16:14:57.298+08:00","updated_at":"2024-07-04T18:10:21.259+08:00","name":"懸崖勒叩叮_預設版","language":"python","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/782382/b0b03d6de4bcd0674c2e1358ad495781.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":54,"hashid":"36ysje3dw","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":17416226,"file_name":"0.png","project_id":782382,"asset_id":752369,"created_at":"2024-07-03T16:16:26.195+08:00","updated_at":"2024-07-03T16:16:26.195+08:00"},{"id":17416227,"file_name":"1.png","project_id":782382,"asset_id":752370,"created_at":"2024-07-03T16:16:26.197+08:00","updated_at":"2024-07-03T16:16:26.197+08:00"},{"id":17416262,"file_name":"r3.png","project_id":782382,"asset_id":752389,"created_at":"2024-07-03T16:16:35.542+08:00","updated_at":"2024-07-03T16:16:35.542+08:00"},{"id":17416263,"file_name":"r4.png","project_id":782382,"asset_id":752390,"created_at":"2024-07-03T16:16:35.544+08:00","updated_at":"2024-07-03T16:16:35.544+08:00"},{"id":17416254,"file_name":"p_0.png","project_id":782382,"asset_id":752381,"created_at":"2024-07-03T16:16:32.739+08:00","updated_at":"2024-07-03T16:16:32.739+08:00"},{"id":17416255,"file_name":"p_1.png","project_id":782382,"asset_id":752382,"created_at":"2024-07-03T16:16:32.741+08:00","updated_at":"2024-07-03T16:16:32.741+08:00"},{"id":17416246,"file_name":"n_2.png","project_id":782382,"asset_id":746771,"created_at":"2024-07-03T16:16:31.235+08:00","updated_at":"2024-07-03T16:16:31.235+08:00"},{"id":17416247,"file_name":"n_3.png","project_id":782382,"asset_id":746772,"created_at":"2024-07-03T16:16:31.237+08:00","updated_at":"2024-07-03T16:16:31.237+08:00"},{"id":17416268,"file_name":"r9.png","project_id":782382,"asset_id":752395,"created_at":"2024-07-03T16:16:37.659+08:00","updated_at":"2024-07-03T16:16:37.659+08:00"},{"id":17416269,"file_name":"space.png","project_id":782382,"asset_id":752396,"created_at":"2024-07-03T16:16:37.660+08:00","updated_at":"2024-07-03T16:16:37.660+08:00"},{"id":17416270,"file_name":"tree.png","project_id":782382,"asset_id":752397,"created_at":"2024-07-03T16:16:38.057+08:00","updated_at":"2024-07-03T16:16:38.057+08:00"},{"id":17416232,"file_name":"6.png","project_id":782382,"asset_id":752375,"created_at":"2024-07-03T16:16:27.485+08:00","updated_at":"2024-07-03T16:16:27.485+08:00"},{"id":17416233,"file_name":"7.png","project_id":782382,"asset_id":752376,"created_at":"2024-07-03T16:16:27.486+08:00","updated_at":"2024-07-03T16:16:27.486+08:00"},{"id":17416234,"file_name":"8.png","project_id":782382,"asset_id":752377,"created_at":"2024-07-03T16:16:27.924+08:00","updated_at":"2024-07-03T16:16:27.924+08:00"},{"id":17416235,"file_name":"9.png","project_id":782382,"asset_id":752378,"created_at":"2024-07-03T16:16:27.926+08:00","updated_at":"2024-07-03T16:16:27.926+08:00"},{"id":17416242,"file_name":"m.png","project_id":782382,"asset_id":746767,"created_at":"2024-07-03T16:16:30.540+08:00","updated_at":"2024-07-03T16:16:30.540+08:00"},{"id":17416243,"file_name":"mountain.png","project_id":782382,"asset_id":746768,"created_at":"2024-07-03T16:16:30.542+08:00","updated_at":"2024-07-03T16:16:30.542+08:00"},{"id":17416256,"file_name":"p_2.png","project_id":782382,"asset_id":752383,"created_at":"2024-07-03T16:16:33.217+08:00","updated_at":"2024-07-03T16:16:33.217+08:00"},{"id":17416257,"file_name":"p_3.png","project_id":782382,"asset_id":752384,"created_at":"2024-07-03T16:16:33.219+08:00","updated_at":"2024-07-03T16:16:33.219+08:00"},{"id":17416230,"file_name":"4.png","project_id":782382,"asset_id":752373,"created_at":"2024-07-03T16:16:27.063+08:00","updated_at":"2024-07-03T16:16:27.063+08:00"},{"id":17416231,"file_name":"5.png","project_id":782382,"asset_id":752374,"created_at":"2024-07-03T16:16:27.064+08:00","updated_at":"2024-07-03T16:16:27.064+08:00"},{"id":17416228,"file_name":"2.png","project_id":782382,"asset_id":752371,"created_at":"2024-07-03T16:16:26.634+08:00","updated_at":"2024-07-03T16:16:26.634+08:00"},{"id":17416229,"file_name":"3.png","project_id":782382,"asset_id":752372,"created_at":"2024-07-03T16:16:26.635+08:00","updated_at":"2024-07-03T16:16:26.635+08:00"},{"id":17416260,"file_name":"r1.png","project_id":782382,"asset_id":752387,"created_at":"2024-07-03T16:16:34.601+08:00","updated_at":"2024-07-03T16:16:34.601+08:00"},{"id":17416261,"file_name":"r2.png","project_id":782382,"asset_id":752388,"created_at":"2024-07-03T16:16:34.602+08:00","updated_at":"2024-07-03T16:16:34.602+08:00"},{"id":17416236,"file_name":"10.png","project_id":782382,"asset_id":752379,"created_at":"2024-07-03T16:16:28.870+08:00","updated_at":"2024-07-03T16:16:28.870+08:00"},{"id":17416244,"file_name":"n_0.png","project_id":782382,"asset_id":746769,"created_at":"2024-07-03T16:16:30.884+08:00","updated_at":"2024-07-03T16:16:30.884+08:00"},{"id":17416245,"file_name":"n_1.png","project_id":782382,"asset_id":746770,"created_at":"2024-07-03T16:16:30.886+08:00","updated_at":"2024-07-03T16:16:30.886+08:00"},{"id":17416266,"file_name":"r7.png","project_id":782382,"asset_id":752393,"created_at":"2024-07-03T16:16:37.050+08:00","updated_at":"2024-07-03T16:16:37.050+08:00"},{"id":17416267,"file_name":"r8.png","project_id":782382,"asset_id":752394,"created_at":"2024-07-03T16:16:37.052+08:00","updated_at":"2024-07-03T16:16:37.052+08:00"},{"id":17416248,"file_name":"n_4.png","project_id":782382,"asset_id":746773,"created_at":"2024-07-03T16:16:31.585+08:00","updated_at":"2024-07-03T16:16:31.585+08:00"},{"id":17416249,"file_name":"n_5.png","project_id":782382,"asset_id":746774,"created_at":"2024-07-03T16:16:31.587+08:00","updated_at":"2024-07-03T16:16:31.587+08:00"},{"id":17416240,"file_name":"g_0.png","project_id":782382,"asset_id":746765,"created_at":"2024-07-03T16:16:30.168+08:00","updated_at":"2024-07-03T16:16:30.168+08:00"},{"id":17416241,"file_name":"g_1.png","project_id":782382,"asset_id":746766,"created_at":"2024-07-03T16:16:30.170+08:00","updated_at":"2024-07-03T16:16:30.170+08:00"},{"id":17416250,"file_name":"n_6.png","project_id":782382,"asset_id":746775,"created_at":"2024-07-03T16:16:31.937+08:00","updated_at":"2024-07-03T16:16:31.937+08:00"},{"id":17416251,"file_name":"n_7.png","project_id":782382,"asset_id":746776,"created_at":"2024-07-03T16:16:31.939+08:00","updated_at":"2024-07-03T16:16:31.939+08:00"},{"id":17416252,"file_name":"n_8.png","project_id":782382,"asset_id":746777,"created_at":"2024-07-03T16:16:32.290+08:00","updated_at":"2024-07-03T16:16:32.290+08:00"},{"id":17416253,"file_name":"n_9.png","project_id":782382,"asset_id":746778,"created_at":"2024-07-03T16:16:32.292+08:00","updated_at":"2024-07-03T16:16:32.292+08:00"},{"id":17416238,"file_name":"bg.png","project_id":782382,"asset_id":746763,"created_at":"2024-07-03T16:16:29.353+08:00","updated_at":"2024-07-03T16:16:29.353+08:00"},{"id":17416239,"file_name":"brake.png","project_id":782382,"asset_id":746764,"created_at":"2024-07-03T16:16:29.355+08:00","updated_at":"2024-07-03T16:16:29.355+08:00"},{"id":17416258,"file_name":"r.png","project_id":782382,"asset_id":752385,"created_at":"2024-07-03T16:16:33.821+08:00","updated_at":"2024-07-03T16:16:33.821+08:00"},{"id":17416259,"file_name":"r0.png","project_id":782382,"asset_id":752386,"created_at":"2024-07-03T16:16:33.822+08:00","updated_at":"2024-07-03T16:16:33.822+08:00"},{"id":17416264,"file_name":"r5.png","project_id":782382,"asset_id":752391,"created_at":"2024-07-03T16:16:36.308+08:00","updated_at":"2024-07-03T16:16:36.308+08:00"},{"id":17416265,"file_name":"r6.png","project_id":782382,"asset_id":752392,"created_at":"2024-07-03T16:16:36.310+08:00","updated_at":"2024-07-03T16:16:36.310+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦