Python 游戏库 Pygame 和 Pyglet 之间的区别? [英] Differences between Python game libraries Pygame and Pyglet?

查看:105
本文介绍了Python 游戏库 Pygame 和 Pyglet 之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Pygame 有一些经验,但最近 Pyglet 似乎有很多嗡嗡声.

I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days.

这两个库如何比较?在功能和易用性方面,使用一种方法比另一种方法有什么优势?

How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use?

最后,你会说一个比另一个更 Pythonic 吗?

Finally, would you say that one is more Pythonic than the other?

推荐答案

我曾考虑将 Pygame 和 Pyglet 用于小型 2D 射击游戏,在查看源代码和一些教程后,我选择了 Pyglet.我对结果非常满意.

I was considering both Pygame and Pyglet for a small 2D shooter, and after looking at source code and some tutorials went with Pyglet. I was very happy with the results.

Pyglet 立即开始工作,使用起来很愉快,并且在概念上非常干净.它对我来说确实有一种 Pythonic 的感觉:你可以很快得到一个简单易读的例子,它使用装饰器来处理事件.它也没有强制特定的程序结构,这让我很容易混合 Pymunk 的物理建模(http://code.google.com/p/pymunk/).

Pyglet worked immediately and was enjoyable to work with, and conceptually very clean. It certainly had a Pythonic feel to me: you could get a straightforward and readable example going very quickly, and it uses decorators to good effect for event handling. It also didn't force a particular program structure, which made it easy for me to mix in the physics modelling of Pymunk (http://code.google.com/p/pymunk/).

虽然它基于 OpenGL,您可以将这些功能用于特殊效果,但我在不了解它们的情况下也能做得很好.

While it is based on OpenGL and you can use those features for special effects, I was able to do just fine without any knowledge of them.

它也适用于 py2exe 和 py2app,这很重要,因为很多人没有安装 Python 解释器.

It also works well with py2exe and py2app, which is important because a lot of people do not have a Python interpreter installed.

不利的一面是,网络上有关它的信息较少,因为它较新,而且可供查看的示例游戏也较少.

On the downside, there is less information about it on the web because it is newer, as well as fewer sample games to look at.

此外,它与以前的版本相比发生了很大的变化,所以现在那里的一些教程已经过时了(有新样式事件循环"和 Sprite 类作为主要补充.)

Also, it changed quite a bit from previous versions, so some of the tutorials which are there are now out of date (there is the "new style event loop" and the Sprite class as major additions.)

我建议您下载示例(其中包含一个名为 Astraea 的不错的 Asteroids 克隆版)并查看您是否喜欢这种风格.

I would recommend downloading the examples (there is a nice Asteroids clone called Astraea included) and seeing if you like the style.

这篇关于Python 游戏库 Pygame 和 Pyglet 之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆