{"id":204993,"student_id":10,"content":"import math #載入數學工具包\nimport random #載入產生隨機數套件\nfrom game import *\n\ngame.set_backdrop('#111111') #設定背景色碼\nbg = create_sprite('tower_0.png', 'tower_1.png') #背景圖\nceiling = create_sprite('ceiling.png') #天花板的針刺\np1 = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png', 'p_4.png') #玩家\np2 = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png', 'p_4.png') #玩家\n\n# 初始化角色位置\u0026圖層\np1.move_to(800, 100)\np2.move_to(400, 100)\nceiling.move_to(600, 18)\nceiling.layer = 1\n\n# 共同變數\nstairs = [] #存放階梯角色\n\n# player 1 的變數\np1_life = 10 #血量\np1_vy = 0 #墜落的速度\np1_floor = 0 #階梯數\np1_touch_on = None #當前踩著的階梯 id\n\n# player 2 的變數\np2_life = 10 #血量\np2_vy = 0 #墜落的速度\np2_floor = 0 #階梯數\np2_touch_on = None #當前踩著的階梯 id\n\n\n#遊戲主迴圈\ndef loop ():\n update_info() #捲動更新背景圖\n update_stairs() #讓所有階梯向上捲動\n update_position() #偵測玩家操控並更新角色位置\n update_costume() #玩家走路動畫\n update_background() #捲動更新背景圖\n gameover_check() #判斷遊戲是否結束\n\n\n#更新遊戲分數\ndef update_info():\n draw_text('分數:' + str(p2_floor), 10, 30, 'white', 30)\n draw_text('生命:' + str(p2_life), 10, 60, 'white', 30)\n draw_text('分數:' + str(p1_floor), 1050, 30, 'white', 30)\n draw_text('生命:' + str(p1_life), 1050, 60, 'white', 30)\n\n\n#捲動更新背景圖\ndef update_background():\n pass\n \n\n#讓所有階梯向上捲動\ndef update_stairs():\n global p1_floor\n\n\n#偵測玩家操控並更新角色位置\ndef update_position():\n global p1_vy, p2_vy\n \n\n#玩家踩到階梯時執行階梯對應的功能\ndef p1_touch_stair(s):\n global p1_touch_on, p1_life, p1_vy\n\n\n#玩家踩到階梯時執行階梯對應的功能\ndef p2_touch_stair(s):\n global p2_touch_on, p2_life, p2_vy\n\n\n#玩家走路動畫\ndef update_costume():\n pass\n\n\n#判斷遊戲是否結束\ndef gameover_check():\n pass\n\n\n# 雙方玩家推擠程式,記得移動的距離必須一樣!\ndef p1p2_interaction():\n if p1.touched(p2):\n if p1.x \u003c p2.x:\n if key.right and key.a == False: p2.x += 8\n if key.right == False and key.a: p1.x -= 8\n if key.right and key.a:\n p1.x -= 8\n p2.x += 8\n else:\n if key.left and key.d == False: p2.x -= 8\n if key.left == False and key.d: p1.x += 8\n if key.left and key.d:\n p1.x += 8\n p2.x -= 8\n\nforever(loop) #重複不斷執行遊戲迴圈\n","created_at":"2020-11-20T14:59:06.888+08:00","updated_at":"2020-12-09T00:33:47.311+08:00","name":"小朋友下樓梯(預設版)","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/204993/eb85c838bfbb67d26c6fb1cec8c7de75.jpg"},"parent_id":151926,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":262,"hashid":"rdvs664wr","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3551367,"file_name":"sky_0.png","project_id":204993,"asset_id":283196,"created_at":"2020-11-20T15:00:10.814+08:00","updated_at":"2020-11-20T15:00:10.814+08:00"},{"id":3551361,"file_name":"s_0.png","project_id":204993,"asset_id":283190,"created_at":"2020-11-20T15:00:08.686+08:00","updated_at":"2020-11-20T15:00:08.686+08:00"},{"id":3551362,"file_name":"s_1.png","project_id":204993,"asset_id":283191,"created_at":"2020-11-20T15:00:08.688+08:00","updated_at":"2020-11-20T15:00:08.688+08:00"},{"id":3551355,"file_name":"ceiling.png","project_id":204993,"asset_id":283189,"created_at":"2020-11-20T15:00:06.420+08:00","updated_at":"2020-11-20T15:00:06.420+08:00"},{"id":3551356,"file_name":"p_0.png","project_id":204993,"asset_id":246920,"created_at":"2020-11-20T15:00:06.424+08:00","updated_at":"2020-11-20T15:00:06.424+08:00"},{"id":3551357,"file_name":"p_1.png","project_id":204993,"asset_id":246921,"created_at":"2020-11-20T15:00:06.961+08:00","updated_at":"2020-11-20T15:00:06.961+08:00"},{"id":3551358,"file_name":"p_2.png","project_id":204993,"asset_id":246922,"created_at":"2020-11-20T15:00:06.963+08:00","updated_at":"2020-11-20T15:00:06.963+08:00"},{"id":3551349,"file_name":"jump.mp3","project_id":204993,"asset_id":36478,"created_at":"2020-11-20T14:59:06.918+08:00","updated_at":"2020-11-20T14:59:06.918+08:00"},{"id":3551350,"file_name":"hit.mp3","project_id":204993,"asset_id":36476,"created_at":"2020-11-20T14:59:06.919+08:00","updated_at":"2020-11-20T14:59:06.919+08:00"},{"id":3551351,"file_name":"gg.mp3","project_id":204993,"asset_id":36479,"created_at":"2020-11-20T14:59:06.921+08:00","updated_at":"2020-11-20T14:59:06.921+08:00"},{"id":3551352,"file_name":"bgm.mp3","project_id":204993,"asset_id":36477,"created_at":"2020-11-20T14:59:06.922+08:00","updated_at":"2020-11-20T14:59:06.922+08:00"},{"id":3551359,"file_name":"p_3.png","project_id":204993,"asset_id":246923,"created_at":"2020-11-20T15:00:08.210+08:00","updated_at":"2020-11-20T15:00:08.210+08:00"},{"id":3551360,"file_name":"p_4.png","project_id":204993,"asset_id":246924,"created_at":"2020-11-20T15:00:08.212+08:00","updated_at":"2020-11-20T15:00:08.212+08:00"},{"id":3551363,"file_name":"s_2.png","project_id":204993,"asset_id":283192,"created_at":"2020-11-20T15:00:09.262+08:00","updated_at":"2020-11-20T15:00:09.262+08:00"},{"id":3551369,"file_name":"tower_0.png","project_id":204993,"asset_id":283197,"created_at":"2020-11-20T15:00:12.428+08:00","updated_at":"2020-11-20T15:00:12.428+08:00"},{"id":3551370,"file_name":"tower_1.png","project_id":204993,"asset_id":283198,"created_at":"2020-11-20T15:00:12.430+08:00","updated_at":"2020-11-20T15:00:12.430+08:00"},{"id":3551366,"file_name":"s_3.png","project_id":204993,"asset_id":283195,"created_at":"2020-11-20T15:00:09.773+08:00","updated_at":"2020-11-20T16:08:58.539+08:00"},{"id":3551365,"file_name":"s_5.png","project_id":204993,"asset_id":283194,"created_at":"2020-11-20T15:00:09.771+08:00","updated_at":"2020-11-20T16:09:00.920+08:00"},{"id":3551364,"file_name":"s_4.png","project_id":204993,"asset_id":283193,"created_at":"2020-11-20T15:00:09.264+08:00","updated_at":"2020-11-20T16:09:03.903+08:00"},{"id":3551368,"file_name":"sky_1.png","project_id":204993,"asset_id":259511,"created_at":"2020-11-20T15:00:10.816+08:00","updated_at":"2020-11-20T15:00:10.816+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦