Pygame

Pygame
開發者pygame Community
首次发布2000年10月28日,​23年前​(2000-10-28[1][2]
当前版本
  • 2.5.2 (2023年9月18日;穩定版本)[3]
編輯維基數據鏈接
源代码库
  • github.com/pygame/pygame/
編輯維基數據鏈接
操作系统跨平台
类型API
许可协议GNU宽通用公共许可证
网站http://www.pygame.org

pygame[5]跨平台Python模块组,专为电子游戏设计。包含图像、声音。建立在SDL基础上,允许实时电子游戏研发而无需被低階语言,如C语言或是更低階的組合語言束缚。基于这样一个设想,所有需要的游戏功能和理念都(主要是图像方面)完全简化位游戏逻辑本身,所有的资源结构都可以由高级语言提供,如Python。

pygame原为代替突然停止的pySDL[6]

pygame在Android

pygame應用程式能夠在Android手機和平板執行,採用pygame對於Android的子集(pgs4a)。[7] 支援Android的聲音,振動,鍵盤和加速。[8]但缺點是沒有辦法在iOS上執行pygame應用程式。其它pgs4a的主要限制是缺乏對於多點觸控的支援, 這使得雙指縮放,以及旋轉無法使用。另一個pygame在Android子集的替代方案是Kivy,[9]它包含了多點觸控及iOS的支援。

例子

這段代碼假設在它運行的同一個目錄中有一個名為 ball.png 的(球的)圖像,它將在窗口中快速移動。[10]


import sys, pygame
pygame.init()
size = width, height = 320, 240
speed = [2, 2]
black = 0, 0, 0
screen = pygame.display.set_mode(size)
ball = pygame.image.load("ball.png")
ballrect = ball.get_rect()
while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: sys.exit()
    ballrect = ballrect.move(speed)
    if ballrect.left < 0 or ballrect.right > width:
        speed[0] = -speed[0]
    if ballrect.top < 0 or ballrect.bottom > height:
        speed[1] = -speed[1]
    screen.fill(black)
    screen.blit(ball, ballrect)
    pygame.display.flip()

其他

  • 自由软件主题
  • 电子游戏主题

展示:

  • Pyweek,游戏制作竞赛,时间限制在7天内
  • Ludum Dare,LD48 游戏制作竞赛,时间限制在48小时内

2D引擎和库:

  • Phil's Pygame Utilities (PGU)(页面存档备份,存于互联网档案馆)是增强pygame的库和工具的集合。工具tile编辑器和一个关卡编辑器。(tile, isometric, hexagonal)GUI增强包括全功能GUI,html渲染,文档输出,文本渲染。函式庫包括精靈和拼接圖電子遊戲引擎(瓷磚圖, 立体圖, 六角圖), 和一個狀態引擎,计时器,高分系统。
  • Pyglet,一个OpenGL库,类似pygame

社群

有定期的競賽,叫做PyWeek. 使用Python寫出遊戲(通常但不一定使用pygame)。[11][12][13]社群已經創造了許多Pygame的教學。[14][15][16][17][18][19]

参考

  1. ^ Shinners, Pete. Python Pygame Introduction - History. [2018-10-18]. (原始内容存档于2019-09-17). 
  2. ^ Downloads - Pygame - Python game development. [2018-10-18]. (原始内容存档于2018-04-13). 
  3. ^ Release 2.5.2. 2023年9月18日 [2023年9月19日]. 
  4. ^ pygame 2.0.1 - The Age Of Aquarius release. GitHub. [2021-05-27]. (原始内容存档于2021-03-22). 
  5. ^ About — wiki. [2019-12-30]. (原始内容存档于2019-09-18). 
  6. ^ Libregamewiki's article on Pygame. [2008-12-19]. (原始内容存档于2008-12-30). 
  7. ^ 存档副本. [2015-09-03]. (原始内容存档于2015-08-10). 
  8. ^ 存档副本. [2014-10-14]. (原始内容存档于2014-10-19). 
  9. ^ 存档副本. [2015-09-03]. (原始内容存档于2015-09-01). 
  10. ^ Zed Shaw. Learn Python the hard way. Addison-Wesley Professional. 2017 [2021-09-21]. ISBN 978-0134692883. (原始内容存档于2021-09-06). 
  11. ^ PyWeek - Python Game Programming Challenge. [2018-08-09]. (原始内容存档于2008-12-17). 
  12. ^ 存档副本. [2018-08-09]. (原始内容存档于2018-08-09). 
  13. ^ 存档副本. [2018-08-09]. (原始内容存档于2020-03-06). 
  14. ^ pygame documentation: Tutorials. [2017-11-12]. (原始内容存档于2017-11-10). 
  15. ^ Shinners, Pete. Line by line tutorial — Tutorial for beginners. [2008-12-19]. (原始内容存档于2005-02-05). 
  16. ^ Creating Games with Python - A tutorial explaining how to use Pygame for game development and improved execution. [2008-12-19]. (原始内容存档于2008-12-20). 
  17. ^ PyGame Tutorials - tutorials with OOP approach. [2018-08-09]. (原始内容存档于2018-08-09). 
  18. ^ pyGame Basics. ShowMeDo.com. [2008-12-19]. (原始内容存档于2007-04-29). 
  19. ^ Arinoid tutorials video tutorials at ShowMeDo. [2008-12-19]. (原始内容存档于2007-04-29). 

链接

  • Pygame homepage—Pygame documentation, wiki, news, download and more.
  • An Introduction to Python Game Programming - written by Rene Dudfield and Geoff Howland
  • Pyweek homepage(页面存档备份,存于互联网档案馆)—regular contest to write a game during one week using Python (most entries use pygame).
  • Pygame newsgroup[永久失效連結] (web access)— the "official" Pygame newsgroup,requires registration
  • Line by line tutorial—Tutorial for beginners by Pete Shinners.
  • Creating Games with Python(页面存档备份,存于互联网档案馆) - A tutorial explaining how to use Pygame for game development and improved execution.
  • pyGame Basics and Arinoid tutorials video tutorials at showmedo
  • Beginning Game Development with Python and Pygame -- A new book discussing game development using Pygame
  • Game Programming the L Line -- A book that introduces programming and game development with Python and pygame
  • pyOpenGL(页面存档备份,存于互联网档案馆) - Python OpenGL Bindings
  • 原始碼移植英语Source port
  • 第一人稱射擊遊戲引擎
    • 列表英语List of first-person shooter engines
  • 遊戲引擎重製英语Game engine recreation
    • 列表英语List of game engine recreations
  • 遊戲創作系統英语Game creation system
  • 遊戲整合開發環境英语Game integrated development environment
  • 视觉小说引擎列表
  • id Tech英语id Tech
專有軟體
1980s
  • Filmation英语Filmation (game engine)
  • Freescape英语Freescape
  • Gold Box英语Gold Box
  • SCUMM
1990s
  • 3D GameStudio英语3D GameStudio
  • Clickteam
  • Dark Engine英语Dark Engine
  • GameMaker
  • Genie Engine英语Genie Engine
  • GoldSrc
  • Jedi英语Jedi (game engine)
  • LithTech英语LithTech
  • M.U.G.E.N
  • Pie in the Sky英语Pie in the Sky (game engine)
  • Reality Lab英语Reality Lab
  • RenderWare
  • RPG製作大師
  • Sim RPG Maker英语Sim RPG Maker
  • 虚幻引擎
  • Virtual Theatre英语Virtual Theatre
  • Voxel Space英语Voxel Space
  • Zero英语Zero (game engine)
  • Zillions of Games
2000s
  • Anvil
  • C4 Engine英语C4 Engine
  • Chrome Engine
  • CryENGINE
  • 水晶工具
  • Diesel英语Diesel (game engine)
  • Ego英语Ego (game engine)
  • Essence Engine英语Essence Engine
  • Euphoria英语Euphoria (software)
  • Flare3D英语Flare3D
  • 寒霜引擎
  • Gamebryo
  • GameSalad英语GameSalad
  • HeroEngine英语HeroEngine
  • IW英语IW (game engine)
  • Leadwerks英语Leadwerks
  • Marmalade SDK英语Marmalade (software)
  • MT Framework
  • PhyreEngine英语PhyreEngine
  • Q英语Q (game engine)
  • RAGE
  • Retro Engine英语Retro Engine
  • SAGE
  • Shark 3D英语Shark 3D
  • Silent Storm engine英语Silent Storm engine
  • Source
  • Titan英语Titan (game engine)
  • Unigine英语Unigine
  • Unity
  • Vicious Engine英语Vicious Engine
  • Vision
  • Visual3D Game Engine英语Visual3D Game Engine
2010s
2020s
  • id Tech 7英语id Tech 7
自由及開源軟體
1970s
  • Z-machine英语Z-machine
1990s
2000s
  • Away3D英语Away3D
  • Blender Game Engine
  • Bork3D Game Engine英语Bork3D Game Engine
  • Cocos2d
  • Dim3英语Dim3
  • Game Editor英语Game Editor
  • GDevelop英语GDevelop
  • id Tech 3
  • id Tech 4
  • Irrlicht Engine英语Irrlicht Engine
  • jMonkeyEngine英语jMonkeyEngine
  • Lightweight Java Game Library英语Lightweight Java Game Library
  • Löve英语Löve (game engine)
  • OGRE
  • Open Wonderland英语Open Wonderland
  • Panda3D英语Panda3D
  • Papervision3D英语Papervision3D
  • Plasma英语Plasma (game engine)
  • Platinum Arts Sandbox英语Platinum Arts Sandbox
  • Pygame
  • Ren'Py
  • Scratch
  • Solar2D英语Solar2D
  • Spring引擎
  • Thousand Parsec
  • Torque英语Torque (game engine)
  • Vassal Engine英语Vassal Engine
  • Wintermute Engine英语Wintermute Engine
2010s
  • Delta3D英语Delta3D
  • Godot
  • GPUOpen英语GPUOpen
  • Horde3D英语Horde3D
  • 吉里吉里
  • libGDX英语libGDX
  • Moai英语Moai (software)
  • OpenFL英语OpenFL
  • ORX英语ORX
  • PlayCanvas英语PlayCanvas
  • Raylib英语Raylib
  • Snap!
  • Stencyl英语Stencyl
  • Stride英语Stride (game engine)
2020s