Toolkit Options for 2D Python Game Programming [cl

2019-03-12 18:28发布

问题:

What are some toolkits for developing 2D games in Python? An option that I have heard of is Pygame, but is there anything that has more range to do more things? What are the good and bad parts about the modules?

回答1:

I use pygame myself and it is very good. It has good documentation and tutorials, and is quite well designed. I've also heard wonderful reviews of pyglet.



回答2:

I have used and would highly recommend pyglet, which provides 2D sprite graphics, hooks into OpenGL effects, audio support, file asset management, and excellent text layout and display support (not something you always find in a 2D game library). The API is sane, well-documented, and easy to get started with, and goes deep (especially if you're an OpenGL wizard).

As a companion to pyglet, I have used and would also suggest Cocos2D, which adds scene management, improved sprites, tiled map support, and fancy (accelerated) effects to add a little polish. Cocos is still young, but taking shape quickly, and already has fairly solid documentation.



回答3:

A blog post covering several of the alternatives, including PyGame, PyCap, SpriteCraft, and ika. I have also seen pyglet mentioned.

You may also want to look at Panda, which is a very easy to use 3D engine with Python bindings. It is used for rapid prototyping at Carnegie Mellon's ETC.



回答4:

I think pygame is the standard for game development in Python, I don't know of any others. A book you may be interested in is Game Programming with Python, Lua, and Ruby. Not only does it cover Python (and, I believe, the pygame module), but it also gives you exposure to Lua and Ruby. It's also available on books24x7 if you have a subscription there.



回答5:

Another option is pycap which is a wrapper for the popcap framework with Python.



回答6:

If you're already familiar with using OpenGL in another language (probably C or C++) then PyOpenGL is awesome. I was surprised as to how easy it was to switch from OpenGL/C to OpenGL/Python. The performance isn't half bad either.

I've heard good things about PyGame and Pyglet though I must admit I haven't really done much messing around with either one.



回答7:

I've only heard people talk about pygame. It has tons of followers & plenty of functionality.

Recently I saw this book at barnes & noble which I might check out one day. It looked good.



回答8:

A followup question:

Can't I just code a simple 2D game inside some existing graphic/windowing toolkit like the excellent wxPython ?

I will benefit from the ready-made GUI widgets that can wrap the graphics in my game, while with pyGame I have to develop those myself.