{"id":190307,"student_id":1806,"content":"import game #載入遊戲框架\nimport random #引入隨機函式庫\n\nsetBackdrop('bg.png') #設定背景圖\np1 = createSprite('pipes.png') #1號水管\np2 = createSprite('pipes.png') #2號水管\np3 = createSprite('pipes.png') #3號水管\ngd = createSprite('ground.png') #地板\nbird = createSprite('bird_1.png', 'bird_2.png') #小鳥\nhint = createSprite('hint.png') #按鍵示意圖\nend = createSprite('gameover.png') #遊戲結束示意圖\n\n#hint.hidden = True這段不需要,改在下面開始的地方\nend.hidden = True\n\nspeed = 0 #鳥的垂直速度\nscore = 0 #遊戲分數\nstart = False #是否開始遊戲\n\np1.x = 0\np2.x = 500\np3.x = 1000\n\n#遊戲迴圈\ndef loop():\n moveGround() #捲動地板\n movePipes(p1) #移動1號水管\n movePipes(p2) #移動2號水管\n movePipes(p3) #移動3號水管\n moveBird() #移動鳥\n game.draw_text(score, 30,30, \"white\", 60) #印出分數\n\n#移動地板\ndef moveGround ():\n #pass不能有空的函數,所pass代替。\n gd.x = gd.x - 6 #讓地板向左移動\n if gd.x \u003c 0: #如果地板x座標小於0\n gd.x = gd.x + 1200; #設定地板x座標一直重複出現\n#移動水管\ndef movePipes (pipe):\n global score\n pipe.x = pipe.x - 6;\n if pipe.x \u003c -100: #微調整,避免水管突然不見\n pipe.x = pipe.x + 1500; #水管間距500\n if start == True:\n pipe.y = random.randrange(150,651) #random.randrange隨機水管高度範圍150到650\n score = score + 1 #水管超出介面就加分\n#鳥的墜落 \u0026 翅膀動畫\ndef moveBird ():\n global speed\n \n if start == True:\n speed = speed + 0.6 #速度下降0.6 python往下是越大\n bird.y = bird.y + speed #鳥的座標是原座標+速度\n \n if bird.y \u003c 50: # 如果鳥超過上標就呼叫gameover\n gameover ()\n \n if speed \u003e 0:\n bird.costume_id = 1\n \n if speed \u003c 0:\n bird.costume_id = 0\n \n#鳥的跳躍\ndef jump ():\n global speed, start\n speed = -12 #當任意按鍵按下時,往上12\n start = True\n hint.hidden = True\n game.create_sound('jump.mp3')\n \n# 遊戲結束\ndef gameover (t):\n pass\n game.stop()\n end.hidden = False\n game.create_sound('gg.mp3')\n\n#新增一個gameover函式\ndef gameover ():\n pass\n game.stop()\n end.hidden = False\n game.create_sound('gg.mp3')\n\nforever(loop) #不斷執行遊戲迴圈\non('keydown', jump) #按下任意按鍵使鳥跳躍\nbird.on('touch', [p1, p2, p3, gd], gameover); #鳥撞到水管或地板就結束遊戲\ngame.create_sound('bgm.mp3',True)\n#=和==差別 變成和條件\n#階層問題會影響\n","created_at":"2020-09-11T23:04:05.580+08:00","updated_at":"2025-05-10T13:49:06.831+08:00","name":"跳躍吧!小鳥_dong","language":"python","screenshot":{"url":"https://cdn6.koding.school/uploads/project/screenshot/190307/1a8751143ccad470d05353353d0c5c28.jpg"},"parent_id":183417,"plugin":"game.set({'width': 1200, 'height': 900})","description":"按下空白鍵開始遊戲\n小提示:建議在兩個管子中間按下開始,不然會很容易一開始就game over喔~","note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":194,"hashid":"wdksqeep","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3241862,"file_name":"bg.png","project_id":190307,"asset_id":251845,"created_at":"2020-09-11T23:04:05.586+08:00","updated_at":"2020-09-11T23:04:05.586+08:00"},{"id":3241863,"file_name":"bird_1.png","project_id":190307,"asset_id":251844,"created_at":"2020-09-11T23:04:05.587+08:00","updated_at":"2020-09-11T23:04:05.587+08:00"},{"id":3241864,"file_name":"bird_2.png","project_id":190307,"asset_id":251843,"created_at":"2020-09-11T23:04:05.588+08:00","updated_at":"2020-09-11T23:04:05.588+08:00"},{"id":3241865,"file_name":"gameover.png","project_id":190307,"asset_id":251842,"created_at":"2020-09-11T23:04:05.589+08:00","updated_at":"2020-09-11T23:04:05.589+08:00"},{"id":3241866,"file_name":"ground.png","project_id":190307,"asset_id":251841,"created_at":"2020-09-11T23:04:05.590+08:00","updated_at":"2020-09-11T23:04:05.590+08:00"},{"id":3241867,"file_name":"pipes.png","project_id":190307,"asset_id":251840,"created_at":"2020-09-11T23:04:05.591+08:00","updated_at":"2020-09-11T23:04:05.591+08:00"},{"id":3241868,"file_name":"bgm.mp3","project_id":190307,"asset_id":251839,"created_at":"2020-09-11T23:04:05.592+08:00","updated_at":"2020-09-11T23:04:05.592+08:00"},{"id":3241869,"file_name":"jump.mp3","project_id":190307,"asset_id":251838,"created_at":"2020-09-11T23:04:05.593+08:00","updated_at":"2020-09-11T23:04:05.593+08:00"},{"id":3241870,"file_name":"gg.mp3","project_id":190307,"asset_id":251837,"created_at":"2020-09-11T23:04:05.594+08:00","updated_at":"2020-09-11T23:04:05.594+08:00"},{"id":3241871,"file_name":"hint.png","project_id":190307,"asset_id":251836,"created_at":"2020-09-11T23:04:05.594+08:00","updated_at":"2020-09-11T23:04:05.594+08:00"}]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
繁中
简中
English
日本語
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦