{"id":830332,"student_id":3760,"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 = -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-08-29T14:42:15.128+08:00","updated_at":"2024-08-29T17:33:33.122+08:00","name":"飛簷走壁","language":"python","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/830332/42364442a0e1111b4bfaeef16e429b0c.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":16,"hashid":"qmdsv94q4","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18269521,"file_name":"wall.png","project_id":830332,"asset_id":772140,"created_at":"2024-08-29T14:42:28.217+08:00","updated_at":"2024-08-29T14:42:28.217+08:00"},{"id":18269522,"file_name":"bgm.mp3","project_id":830332,"asset_id":772141,"created_at":"2024-08-29T14:42:28.227+08:00","updated_at":"2024-08-29T14:42:28.227+08:00"},{"id":18269523,"file_name":"trees.png","project_id":830332,"asset_id":772142,"created_at":"2024-08-29T14:42:28.232+08:00","updated_at":"2024-08-29T14:42:28.232+08:00"},{"id":18269524,"file_name":"bg.png","project_id":830332,"asset_id":772143,"created_at":"2024-08-29T14:42:28.238+08:00","updated_at":"2024-08-29T14:42:28.238+08:00"},{"id":18269525,"file_name":"boom.png","project_id":830332,"asset_id":772144,"created_at":"2024-08-29T14:42:28.242+08:00","updated_at":"2024-08-29T14:42:28.242+08:00"},{"id":18269526,"file_name":"c_2.png","project_id":830332,"asset_id":772145,"created_at":"2024-08-29T14:42:28.247+08:00","updated_at":"2024-08-29T14:42:28.247+08:00"},{"id":18269527,"file_name":"ing.png","project_id":830332,"asset_id":772146,"created_at":"2024-08-29T14:42:28.254+08:00","updated_at":"2024-08-29T14:42:28.254+08:00"},{"id":18269528,"file_name":"l_0.png","project_id":830332,"asset_id":772147,"created_at":"2024-08-29T14:42:28.261+08:00","updated_at":"2024-08-29T14:42:28.261+08:00"},{"id":18269529,"file_name":"l_1.png","project_id":830332,"asset_id":772148,"created_at":"2024-08-29T14:42:28.266+08:00","updated_at":"2024-08-29T14:42:28.266+08:00"},{"id":18269530,"file_name":"l_2.png","project_id":830332,"asset_id":772149,"created_at":"2024-08-29T14:42:28.270+08:00","updated_at":"2024-08-29T14:42:28.270+08:00"},{"id":18269531,"file_name":"p_0.png","project_id":830332,"asset_id":772150,"created_at":"2024-08-29T14:42:28.275+08:00","updated_at":"2024-08-29T14:42:28.275+08:00"},{"id":18269532,"file_name":"p_1.png","project_id":830332,"asset_id":772151,"created_at":"2024-08-29T14:42:28.280+08:00","updated_at":"2024-08-29T14:42:28.280+08:00"},{"id":18269533,"file_name":"p_2.png","project_id":830332,"asset_id":772152,"created_at":"2024-08-29T14:42:28.284+08:00","updated_at":"2024-08-29T14:42:28.284+08:00"},{"id":18269534,"file_name":"p_3.png","project_id":830332,"asset_id":772153,"created_at":"2024-08-29T14:42:28.289+08:00","updated_at":"2024-08-29T14:42:28.289+08:00"},{"id":18269535,"file_name":"p_4.png","project_id":830332,"asset_id":772154,"created_at":"2024-08-29T14:42:28.293+08:00","updated_at":"2024-08-29T14:42:28.293+08:00"},{"id":18269536,"file_name":"r_2.png","project_id":830332,"asset_id":772155,"created_at":"2024-08-29T14:42:28.297+08:00","updated_at":"2024-08-29T14:42:28.297+08:00"},{"id":18269537,"file_name":"rules.png","project_id":830332,"asset_id":772156,"created_at":"2024-08-29T14:42:28.303+08:00","updated_at":"2024-08-29T14:42:28.303+08:00"},{"id":18269538,"file_name":"c_0.png","project_id":830332,"asset_id":772157,"created_at":"2024-08-29T14:42:28.309+08:00","updated_at":"2024-08-29T14:42:28.309+08:00"},{"id":18269539,"file_name":"c_1.png","project_id":830332,"asset_id":772158,"created_at":"2024-08-29T14:42:28.313+08:00","updated_at":"2024-08-29T14:42:28.313+08:00"},{"id":18269540,"file_name":"r_0.png","project_id":830332,"asset_id":772159,"created_at":"2024-08-29T14:42:28.318+08:00","updated_at":"2024-08-29T14:42:28.318+08:00"},{"id":18269541,"file_name":"r_1.png","project_id":830332,"asset_id":772160,"created_at":"2024-08-29T14:42:28.323+08:00","updated_at":"2024-08-29T14:42:28.323+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦