Pygame 遊戲設計:鍵盤控制角色移動

Ping-Lun Liao
2 min readJun 3, 2019

--

本篇文章展示如何使用Pygame來控制遊戲中角色的移動。可參考此篇教學:「 Day27-安裝使用PyGame套件」來安裝 Pygame;或是使用有內建Pygame的 Mu Code Editor,本文將使用 Mu Code Editor來示範。開啟Mu Editor後,要先設定程式碼撰寫的模式(Mode),請點選Mu Editor左上角的 Mode圖示:

選擇Pygame Zero:

按下 New 的圖示:

接著就要開始寫程式了!程式碼如下:

參考資料:
[1] https://techwithtim.net/tutorials/game-development-with-python/pygame-tutorial/pygame-tutorial-movement/

Originally published at https://yunlinsong.blogspot.com.

--

--

No responses yet