pygame
跳转到导航
跳转到搜索
脚本错误:没有“Message box”这个模块。 Template:NoteTA Template:Infobox Software pygame[1]是跨平台Python模块组,专为电子游戏设计。包含图像、声音。建立在SDL基础上,允许实时电子游戏研发而无需被低阶语言,如C语言或是更低阶的组合语言束缚。基于这样一个设想,所有需要的游戏功能和理念都(主要是图像方面)完全简化位游戏逻辑本身,所有的资源结构都可以由高级语言提供,如Python。
pygame原为代替突然停止的pySDL[2]。
pygame在Android[编辑]
pygame应用程序能够在Android手机和平板执行,采用pygame对于Android的子集(pgs4a)。[3] 支援Android的声音,振动,键盘和加速。[4]但缺点是没有办法在iOS上执行pygame应用程序。其它pgs4a的主要限制是缺乏对于多点触控的支援, 这使得双指缩放,以及旋转无法使用。另一个pygame在Android子集的替代方案是Kivy,[5]它包含了多点触控及iOS的支援。
例子[编辑]
这段代码假设在它运行的同一个目录中有一个名为 ball.png 的(球的)图像,它将在窗口中快速移动。[6]
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()
其他[编辑]
脚本错误:没有“Portal”这个模块。 脚本错误:没有“Portal”这个模块。 展示:
- Pyweek,游戏制作竞赛,时间限制在7天内
- Ludum Dare,LD48 游戏制作竞赛,时间限制在48小时内
2D引擎和库:
- Phil's Pygame Utilities (PGU)(页面存档备份,存于互联网档案馆)是增强pygame的库和工具的集合。工具tile编辑器和一个关卡编辑器。(tile, isometric, hexagonal)GUI增强包括全功能GUI,html渲染,文档输出,文本渲染。函式库包括精灵和拼接图电子游戏引擎(瓷砖图, 立体图, 六角图), 和一个状态引擎,计时器,高分系统。
- Pyglet,一个OpenGL库,类似pygame
社群[编辑]
脚本错误:没有“anchor”这个模块。 有定期的竞赛,叫做PyWeek. 使用Python写出游戏(通常但不一定使用pygame)。[7][8][9]社群已经创造了许多Pygame的教学。[10][11][12][13][14][15]
参考[编辑]
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite book
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ Template:Cite web
链接[编辑]
- 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脚本错误:没有“Unsubst”这个模块。 (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