{"id":863574,"student_id":1981,"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#移動岩壁\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-15T16:06:10.823+08:00","updated_at":"2024-10-15T16:06:10.823+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":3,"hashid":"2pdspwvpe","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18911564,"file_name":"bgm.mp3","project_id":863574,"asset_id":771353,"created_at":"2024-10-15T16:06:10.828+08:00","updated_at":"2024-10-15T16:06:10.828+08:00"},{"id":18911565,"file_name":"wall.png","project_id":863574,"asset_id":771354,"created_at":"2024-10-15T16:06:10.829+08:00","updated_at":"2024-10-15T16:06:10.829+08:00"},{"id":18911566,"file_name":"trees.png","project_id":863574,"asset_id":771355,"created_at":"2024-10-15T16:06:10.830+08:00","updated_at":"2024-10-15T16:06:10.830+08:00"},{"id":18911567,"file_name":"bg.png","project_id":863574,"asset_id":771356,"created_at":"2024-10-15T16:06:10.831+08:00","updated_at":"2024-10-15T16:06:10.831+08:00"},{"id":18911568,"file_name":"boom.png","project_id":863574,"asset_id":771357,"created_at":"2024-10-15T16:06:10.832+08:00","updated_at":"2024-10-15T16:06:10.832+08:00"},{"id":18911569,"file_name":"c_2.png","project_id":863574,"asset_id":771358,"created_at":"2024-10-15T16:06:10.833+08:00","updated_at":"2024-10-15T16:06:10.833+08:00"},{"id":18911570,"file_name":"l_0.png","project_id":863574,"asset_id":771359,"created_at":"2024-10-15T16:06:10.834+08:00","updated_at":"2024-10-15T16:06:10.834+08:00"},{"id":18911571,"file_name":"l_1.png","project_id":863574,"asset_id":771360,"created_at":"2024-10-15T16:06:10.835+08:00","updated_at":"2024-10-15T16:06:10.835+08:00"},{"id":18911572,"file_name":"l_2.png","project_id":863574,"asset_id":771361,"created_at":"2024-10-15T16:06:10.836+08:00","updated_at":"2024-10-15T16:06:10.836+08:00"},{"id":18911573,"file_name":"p_0.png","project_id":863574,"asset_id":771362,"created_at":"2024-10-15T16:06:10.837+08:00","updated_at":"2024-10-15T16:06:10.837+08:00"},{"id":18911574,"file_name":"p_1.png","project_id":863574,"asset_id":771363,"created_at":"2024-10-15T16:06:10.838+08:00","updated_at":"2024-10-15T16:06:10.838+08:00"},{"id":18911575,"file_name":"p_2.png","project_id":863574,"asset_id":771364,"created_at":"2024-10-15T16:06:10.839+08:00","updated_at":"2024-10-15T16:06:10.839+08:00"},{"id":18911576,"file_name":"p_3.png","project_id":863574,"asset_id":771365,"created_at":"2024-10-15T16:06:10.840+08:00","updated_at":"2024-10-15T16:06:10.840+08:00"},{"id":18911577,"file_name":"p_4.png","project_id":863574,"asset_id":771366,"created_at":"2024-10-15T16:06:10.841+08:00","updated_at":"2024-10-15T16:06:10.841+08:00"},{"id":18911578,"file_name":"r_2.png","project_id":863574,"asset_id":771367,"created_at":"2024-10-15T16:06:10.842+08:00","updated_at":"2024-10-15T16:06:10.842+08:00"},{"id":18911579,"file_name":"rules.png","project_id":863574,"asset_id":771368,"created_at":"2024-10-15T16:06:10.843+08:00","updated_at":"2024-10-15T16:06:10.843+08:00"},{"id":18911580,"file_name":"c_0.png","project_id":863574,"asset_id":771369,"created_at":"2024-10-15T16:06:10.844+08:00","updated_at":"2024-10-15T16:06:10.844+08:00"},{"id":18911581,"file_name":"c_1.png","project_id":863574,"asset_id":771370,"created_at":"2024-10-15T16:06:10.845+08:00","updated_at":"2024-10-15T16:06:10.845+08:00"},{"id":18911582,"file_name":"r_0.png","project_id":863574,"asset_id":771371,"created_at":"2024-10-15T16:06:10.846+08:00","updated_at":"2024-10-15T16:06:10.846+08:00"},{"id":18911583,"file_name":"r_1.png","project_id":863574,"asset_id":771372,"created_at":"2024-10-15T16:06:10.847+08:00","updated_at":"2024-10-15T16:06:10.847+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦