pygame 和 pyglet 的优缺点

发布于 2024-08-02 00:07:19 字数 1433 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寂寞陪衬 2024-08-09 00:07:19

pygame 非常活跃,见证 8 月发布的 1.9 版本,它支持诺基亚 s60、增强的 py2app/py2exe 支持以及一系列实验性功能(支持 Python 3.1、网络摄像头、gfx 等)。 Hello World 等书籍以及定期举办的有趣竞赛,例如 ludumdarepyweek 见证了其社区的活力和生态系统。

pyglet 有一个简洁、更新的 API,并且很方便(纯 Python,BSD 许可证而不是 LGPL)。

至于速度,我没有运行任何基准测试,但我认为开箱即用的 pyglet 更擅长利用高级硬件加速进行 3D 工作,而 pygame 更擅长 2D 工作,而在硬件上则没有那么先进(智能手机、上网本、等等,没有闪亮的 3D 硬件加速器)。 您可以通过附加组件来提高这两个框架的速度,但这确实会失去便利性。

在 Py3 支持等方面,我认为问题很简单,因为 pygame 更加成熟和流行,拥有更大的核心开发团队,所以它当然可以更早地获得像 Py3 支持这样的新东西。

如果上述问题对您来说都不是决定性的(您对 LGPL 与 BSD 都满意,不太关心智能手机,不需要书籍等),那么唯一明智的方法就是下载两者并尝试相同的方法在您感兴趣的机器上执行您感兴趣的基本任务——这将告诉您每个任务“适合您的大脑”的程度,您对速度、便利性的需求等等。

pygame is richly active, witness the Aug release of 1.9 with nokia s60 support, enhanced py2app/py2exe support, and a bevvy of experimental features (support for Python 3.1, webcams, gfx, ...). Books like Hello World and periodic, fun competitions like ludumdare and pyweek bear witness to the vitality of its community and ecosystem.

pyglet has a neat, newer API, and is convenient (pure Python, BSD license instead of LGPL).

As for speed, I've run no benchmarks but I gather that out of the box pyglet is better at exploiting advanced HW acceleration for 3D work, while pygame is better at 2D work and on HW that's nowhere as advanced (smart phones, netbooks, etc, don't have shiny 3D HW accelerators). You can enhance both frameworks' speed with add-ons, though that does lose convenience.

In terms of Py3 support etc, I believe the issue is simply that pygame, much more mature and popular, has a vastly larger core development group, so of course it can get new things like Py3 support out of the gate earlier.

If none of the above issues is decisive for you (you're fine with LGPL vs BSD, don't care much about smartphones, need no books, etc, etc), the only sensible approach is really to download both and try the same elementary tasks of your interest on machines of your interest -- that will tell you how well each "fits your brain", your need for speed, convenience, and so forth.

岁月流歌 2024-08-09 00:07:19

我无法评论其他答案,所以我必须提出这个新答案,抱歉。

速度方面, Pyglet 肯定比 pygame 开箱即用,使用 pygame 开发时速度始终是一个问题(您必须更新屏幕的最小部分,并且记住发生了什么变化可以很乏味)。 pyglet 不存在这样的问题。

如果您使用 cocos2d (pyglet 之上的一层)加速事情会更容易,只需将精灵附加到 BatchNode,然后观察 FPS 的上升。

正如评论中所说,pyglet 作为 python3 支持。

这只是我个人的喜好,但我更喜欢 Pyglet,而且加上 cocos2d,它真的很容易学习。 缺点是社区小得多。

I cannot comment other answers, so I have to make this new one, sorry.

Speed-wise, Pyglet is definitely faster than pygame out-of-the-box, and speed is always a concern when developing with pygame (you have to update the smallest parts of screen, and remembering what has changed can be tedious). There is no such issue with pyglet.

If you use cocos2d (a layer above pyglet) speeding-up things is even easier, just attach sprites to a BatchNode, and watch the FPS rise.

As said in a comment pyglet as python3 support.

It's just my personal preference, but I like Pyglet much more, and with cocos2d on top, it's really easy to learn. The downside is the much smaller community.

2024-08-09 00:07:19

这似乎是以下内容的重复: Python 游戏库 Pygame 和 Pyglet 之间的差异?

这至少是一个寻找其他答案的地方。

我参加了 Steve Johnson 在 PyOhio 上关于 pyglet 的演讲(演讲 #18,位于 http://pyohio.org/2009/Talks /),并且对所涉及的代码之少印象深刻。 pygame 看起来很大,我(个人)不关心所有额外的依赖项。

也就是说,我还没有为两者编写任何代码。 我的计划是从 pyglet 开始,然后在我熟悉它之后,尝试 pygame 并看看它们如何比较。

我同意亚历克斯的回答,如果你用谷歌搜索 pygame 与 pyglet,你会发现很多个人喜好。 我看到的唯一客观差异是支持多少显卡的差异(pygame 不需要 OpenGL,因此 pygame 可以支持更多)。

This seems like a duplicate of: Differences between Python game libraries Pygame and Pyglet?

That is at least one place to look for additional answers.

I attended Steve Johnson's talk on pyglet at PyOhio (Talk #18 at http://pyohio.org/2009/Talks/) and came away quite impressed with just how little code was involved. pygame seems large and I (personally) do not care for all the extra dependencies.

That said, I haven't yet written any code for either. My plan is to start with pyglet and then after I'm comfortable with it, try pygame and see how they compare.

I concur with Alex's response, if you google for pygame vs. pyglet, you'll find a lot of personal preferences. About the only objective difference I saw was the difference in how many graphics cards are supported (pygame doesn't require OpenGL so pygame can support more).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文