What can Pygame do in terms of graphics that wxPython can't?

前端 未结 2 1538
醉梦人生
醉梦人生 2021-02-19 00:58

I want to develop a very simple 2D game in Python. Pygame is the most popular library for game development in Python, but I\'m already quite familiar with wxPython and feel comf

相关标签:
2条回答
  • 2021-02-19 01:52

    wxPython is based on wxWidgets which is a GUI-oriented toolkit. It has the advantage of using the styles and decorations provided by the system it runs on and thus it is very easy to write portable applications that integrate nicely into the look and feel of whatever you're running. You want a checkbox? Use wxCheckBox and wxPython will handle looks and interaction.

    pyGame, on the other hand, is oriented towards game development and thus brings you closer to the hardware in ways wxPython doesn't (and doesn't need to, since it calls the OS for drawing most of its controls). pyGame has lots of game related stuff like collision detection, fine-grained control of surfaces and layers or flipping display buffers at a time of your choosing.

    That said, graphics-wise you can probably always find a way to do what you want with both toolkits. However, when speed counts or you wish to implement graphically more taxing game ideas than Tetris, you're probably better off with pyGame. If you want to use lots of GUI elements and don't need the fancy graphics and sound functions, you're better off with wxPython.

    Portability is not an issue. Both are available for the big three (Linux, OSX, Windows).

    It's more a question of what kind of special capabilities you need, really.

    0 讨论(0)
  • 2021-02-19 01:56

    Well, in theory there is nothing you can do with Pygame that you can't with wxPython. The point is not what but how. In my opinion, it's easier to write a game with PyGame becasue:

    • It's faster. Pygame is based on SDL which is a C library specifically designed for games, it has been developed with speed in mind. When you develop games, you need speed.

    • Is a game library, not a general purpose canvas, It has classes and functions useful for sprites, transformations, input handling, drawing, collision detection. It also implements algorithms and techniques often used in games like dirty rectangles, page flipping, etc.

    • There are thousands of games and examples made with it. It will be easier for you to discover how to do any trick.

    • There are a lot of libraries with effects and utilities you could reuse. You want an isometric game, there is a library, you want a physics engine, there is a library, you what some cool visual effect, there is a library.

    • PyWeek. :) This is to make the development of your game even funnier!

    For some very simple games like Tetris, the difference won't be too much, but if you want to develop a fairly complex game, believe me, you will want something like PyGame.

    0 讨论(0)
提交回复
热议问题