{"id":830325,"student_id":2589,"content":"from game import *\nfrom random import *\n\nbg = create_sprite('bg.png') #背景\ntree = create_sprite('trees.png') #樹林\nwall = create_sprite('wall.png') #岩壁\nobj_1 = create_sprite('l_0.png', 'l_1.png', 'l_2.png') #左側障礙物\nobj_2 = create_sprite('c_0.png', 'c_1.png', 'c_2.png') #中間障礙物\nobj_3 = create_sprite('r_0.png', 'r_1.png', 'r_2.png') #右側障礙物\nplayer = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png', 'p_4.png') #玩家\nboom = create_sprite('boom.png') #爆炸圖\nrules = create_sprite('rules.png') #遊戲說明\n# create_sound('bgm.mp3', True) #背景音樂\n\nbg.y = 0\nwall.y = -1800\nobj_1.move_to(200, 0)\nobj_2.move_to(600, -1000)\nobj_3.move_to(1000, -2000)\nplayer.move_to(1000, 800)\nboom.move_to(600, -1000)\n\nratio = 0 #斜率\nspeed = 1 #速度\nmoved = 3000 #攀爬高度\n\ndef loop():\n global speed, moved\n \n if key.space: rules.hidden = True #按下空白鍵隱藏規則說明\n \n #如果遊戲說明隱藏而且玩家並非等待造型就開始更新角色\n if rules.hidden and player.costume_id != 0:\n update_obj(obj_1) #更新左側障礙物\n update_obj(obj_2) #更新中間障礙物\n update_obj(obj_3) #更新右側障礙物\n update_wall() #移動岩壁\n update_player() #移動玩家\n update_background() #移動背景\n speed += 0.0005 #加快速度\n moved += speed #紀錄攀爬高度\n draw_text(int(moved / 100), 30, 30, 'white', 80) #在畫面上顯示移動距離\n\n#更新玩家\ndef update_player():\n \n #向左飛行\n if player.costume_id == 1:\n player.x -= speed * 10\n player.y -= speed * 10 * ratio\n if player.x \u003c= 200:\n player.costume_id = 2\n \n #向右飛行\n if player.costume_id == 3:\n player.x += speed * 10\n player.y -= speed * 10 * ratio\n if player.x \u003e= 1000:\n player.costume_id = 4\n \n #向左和向右趴著\n if player.costume_id == 2 or player.costume_id == 4:\n player.y += speed * 1.5\n \n if player.y \u003e 1000: stop() #如果玩家的y座標超過1000,停止遊戲\n\n#更新障礙物\ndef update_obj(s):\n s.y += speed\n if s.y \u003e 1000:\n s.y -= 3000\n s.y += random() * 500 - 250\n s.costume_id = randrange(3)\n \n #如果障礙物與玩家距離小於 100 就顯示爆炸圖並停止遊戲\n if s.distance_to(player) \u003c 100:\n boom.x = (player.x + s.x) / 2\n boom.y = (player.y + s.y) / 2\n stop()\n \n#移動岩壁\ndef update_wall():\n wall.y += speed\n if wall.y \u003e 900: wall.y -= 1800\n \n#動背景與樹林\ndef update_background():\n if bg.y \u003c 900: bg.y += 0.1\n if tree.y \u003c 900: tree.y += 0.1\n \n#當點擊畫面時\ndef click():\n global ratio\n ratio = (player.y - cursor.y) / 800 #計算垂直相對水平移動的比例\n if player.costume_id == 0: player.costume_id = 1 ##等待造型就切換至向左飛\n elif player.costume_id == 2: player.costume_id = 3 #向右攀爬就切換至向左飛\n elif player.costume_id == 4: player.costume_id = 1 #向左攀爬就切換至向右飛\n\nforever(loop) #不斷執行遊戲迴圈\non('click', click) #當點擊畫面時執行 click 函式\n\n","created_at":"2024-08-29T13:45:30.858+08:00","updated_at":"2024-08-29T13:45:30.858+08:00","name":"5_飛簷走壁_預設版 副本","language":"python","screenshot":{"url":null},"parent_id":829932,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":12,"hashid":"gk4s859dj","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18269303,"file_name":"bgm.mp3","project_id":830325,"asset_id":771353,"created_at":"2024-08-29T13:45:30.863+08:00","updated_at":"2024-08-29T13:45:30.863+08:00"},{"id":18269304,"file_name":"wall.png","project_id":830325,"asset_id":771354,"created_at":"2024-08-29T13:45:30.864+08:00","updated_at":"2024-08-29T13:45:30.864+08:00"},{"id":18269305,"file_name":"trees.png","project_id":830325,"asset_id":771355,"created_at":"2024-08-29T13:45:30.865+08:00","updated_at":"2024-08-29T13:45:30.865+08:00"},{"id":18269306,"file_name":"bg.png","project_id":830325,"asset_id":771356,"created_at":"2024-08-29T13:45:30.866+08:00","updated_at":"2024-08-29T13:45:30.866+08:00"},{"id":18269307,"file_name":"boom.png","project_id":830325,"asset_id":771357,"created_at":"2024-08-29T13:45:30.867+08:00","updated_at":"2024-08-29T13:45:30.867+08:00"},{"id":18269308,"file_name":"c_2.png","project_id":830325,"asset_id":771358,"created_at":"2024-08-29T13:45:30.868+08:00","updated_at":"2024-08-29T13:45:30.868+08:00"},{"id":18269309,"file_name":"l_0.png","project_id":830325,"asset_id":771359,"created_at":"2024-08-29T13:45:30.869+08:00","updated_at":"2024-08-29T13:45:30.869+08:00"},{"id":18269310,"file_name":"l_1.png","project_id":830325,"asset_id":771360,"created_at":"2024-08-29T13:45:30.870+08:00","updated_at":"2024-08-29T13:45:30.870+08:00"},{"id":18269311,"file_name":"l_2.png","project_id":830325,"asset_id":771361,"created_at":"2024-08-29T13:45:30.871+08:00","updated_at":"2024-08-29T13:45:30.871+08:00"},{"id":18269312,"file_name":"p_0.png","project_id":830325,"asset_id":771362,"created_at":"2024-08-29T13:45:30.872+08:00","updated_at":"2024-08-29T13:45:30.872+08:00"},{"id":18269313,"file_name":"p_1.png","project_id":830325,"asset_id":771363,"created_at":"2024-08-29T13:45:30.873+08:00","updated_at":"2024-08-29T13:45:30.873+08:00"},{"id":18269314,"file_name":"p_2.png","project_id":830325,"asset_id":771364,"created_at":"2024-08-29T13:45:30.873+08:00","updated_at":"2024-08-29T13:45:30.873+08:00"},{"id":18269315,"file_name":"p_3.png","project_id":830325,"asset_id":771365,"created_at":"2024-08-29T13:45:30.874+08:00","updated_at":"2024-08-29T13:45:30.874+08:00"},{"id":18269316,"file_name":"p_4.png","project_id":830325,"asset_id":771366,"created_at":"2024-08-29T13:45:30.875+08:00","updated_at":"2024-08-29T13:45:30.875+08:00"},{"id":18269317,"file_name":"r_2.png","project_id":830325,"asset_id":771367,"created_at":"2024-08-29T13:45:30.876+08:00","updated_at":"2024-08-29T13:45:30.876+08:00"},{"id":18269318,"file_name":"rules.png","project_id":830325,"asset_id":771368,"created_at":"2024-08-29T13:45:30.877+08:00","updated_at":"2024-08-29T13:45:30.877+08:00"},{"id":18269319,"file_name":"c_0.png","project_id":830325,"asset_id":771369,"created_at":"2024-08-29T13:45:30.878+08:00","updated_at":"2024-08-29T13:45:30.878+08:00"},{"id":18269320,"file_name":"c_1.png","project_id":830325,"asset_id":771370,"created_at":"2024-08-29T13:45:30.879+08:00","updated_at":"2024-08-29T13:45:30.879+08:00"},{"id":18269321,"file_name":"r_0.png","project_id":830325,"asset_id":771371,"created_at":"2024-08-29T13:45:30.880+08:00","updated_at":"2024-08-29T13:45:30.880+08:00"},{"id":18269322,"file_name":"r_1.png","project_id":830325,"asset_id":771372,"created_at":"2024-08-29T13:45:30.881+08:00","updated_at":"2024-08-29T13:45:30.881+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦