{"id":857575,"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') #遊戲說明\ncreate_sound('bgm.mp3', True) #背景音樂\n\nbg.y = 0\nwall.y = -900\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 = 0 #攀爬高度\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(str(moved // 100) + 'm', 30, 30, 'white', 60) #在畫面上顯示移動距離\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-10-07T11:59:23.343+08:00","updated_at":"2024-10-07T11:59:43.211+08:00","name":"5_飛簷走壁_完整版","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":7,"hashid":"rdvsdgrrq","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18806254,"file_name":"wall.png","project_id":857575,"asset_id":781589,"created_at":"2024-10-07T11:59:43.105+08:00","updated_at":"2024-10-07T11:59:43.105+08:00"},{"id":18806255,"file_name":"bgm.mp3","project_id":857575,"asset_id":781590,"created_at":"2024-10-07T11:59:43.116+08:00","updated_at":"2024-10-07T11:59:43.116+08:00"},{"id":18806256,"file_name":"trees.png","project_id":857575,"asset_id":781591,"created_at":"2024-10-07T11:59:43.123+08:00","updated_at":"2024-10-07T11:59:43.123+08:00"},{"id":18806257,"file_name":"bg.png","project_id":857575,"asset_id":781592,"created_at":"2024-10-07T11:59:43.128+08:00","updated_at":"2024-10-07T11:59:43.128+08:00"},{"id":18806258,"file_name":"boom.png","project_id":857575,"asset_id":781593,"created_at":"2024-10-07T11:59:43.134+08:00","updated_at":"2024-10-07T11:59:43.134+08:00"},{"id":18806259,"file_name":"c_2.png","project_id":857575,"asset_id":781594,"created_at":"2024-10-07T11:59:43.138+08:00","updated_at":"2024-10-07T11:59:43.138+08:00"},{"id":18806260,"file_name":"ing.png","project_id":857575,"asset_id":781595,"created_at":"2024-10-07T11:59:43.144+08:00","updated_at":"2024-10-07T11:59:43.144+08:00"},{"id":18806261,"file_name":"l_0.png","project_id":857575,"asset_id":781596,"created_at":"2024-10-07T11:59:43.151+08:00","updated_at":"2024-10-07T11:59:43.151+08:00"},{"id":18806262,"file_name":"l_1.png","project_id":857575,"asset_id":781597,"created_at":"2024-10-07T11:59:43.156+08:00","updated_at":"2024-10-07T11:59:43.156+08:00"},{"id":18806263,"file_name":"l_2.png","project_id":857575,"asset_id":781598,"created_at":"2024-10-07T11:59:43.160+08:00","updated_at":"2024-10-07T11:59:43.160+08:00"},{"id":18806264,"file_name":"p_0.png","project_id":857575,"asset_id":781599,"created_at":"2024-10-07T11:59:43.164+08:00","updated_at":"2024-10-07T11:59:43.164+08:00"},{"id":18806265,"file_name":"p_1.png","project_id":857575,"asset_id":781600,"created_at":"2024-10-07T11:59:43.168+08:00","updated_at":"2024-10-07T11:59:43.168+08:00"},{"id":18806266,"file_name":"p_2.png","project_id":857575,"asset_id":781601,"created_at":"2024-10-07T11:59:43.173+08:00","updated_at":"2024-10-07T11:59:43.173+08:00"},{"id":18806267,"file_name":"p_3.png","project_id":857575,"asset_id":781602,"created_at":"2024-10-07T11:59:43.177+08:00","updated_at":"2024-10-07T11:59:43.177+08:00"},{"id":18806268,"file_name":"p_4.png","project_id":857575,"asset_id":781603,"created_at":"2024-10-07T11:59:43.182+08:00","updated_at":"2024-10-07T11:59:43.182+08:00"},{"id":18806269,"file_name":"r_2.png","project_id":857575,"asset_id":781604,"created_at":"2024-10-07T11:59:43.186+08:00","updated_at":"2024-10-07T11:59:43.186+08:00"},{"id":18806270,"file_name":"rules.png","project_id":857575,"asset_id":781605,"created_at":"2024-10-07T11:59:43.191+08:00","updated_at":"2024-10-07T11:59:43.191+08:00"},{"id":18806271,"file_name":"c_0.png","project_id":857575,"asset_id":781606,"created_at":"2024-10-07T11:59:43.196+08:00","updated_at":"2024-10-07T11:59:43.196+08:00"},{"id":18806272,"file_name":"c_1.png","project_id":857575,"asset_id":781607,"created_at":"2024-10-07T11:59:43.200+08:00","updated_at":"2024-10-07T11:59:43.200+08:00"},{"id":18806273,"file_name":"r_0.png","project_id":857575,"asset_id":781608,"created_at":"2024-10-07T11:59:43.205+08:00","updated_at":"2024-10-07T11:59:43.205+08:00"},{"id":18806274,"file_name":"r_1.png","project_id":857575,"asset_id":781609,"created_at":"2024-10-07T11:59:43.210+08:00","updated_at":"2024-10-07T11:59:43.210+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦