LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Anybody used pygame before? How easy is it to use? (http://www.linuxquestions.org/questions/programming-9/anybody-used-pygame-before-how-easy-is-it-to-use-468055/)

vharishankar 07-26-2006 09:22 PM

Anybody used pygame before? How easy is it to use?
 
I'm talking about fairly serious game programming using pygame. How easy/difficult is it to create a full fledged game using this kit and what are the strategies you would adopt in building a game skeleton/engine which can be used for serious game development?

What are the advantages and disadvantages of using pygame?

CroMagnon 07-27-2006 12:21 PM

I wrote up a clone of Tetris in about an hour using PyGame, and I'd never used it before, so I'd say it is pretty easy! I'm not sure what you mean by "serious" game development, but I'd say the most likely issue would be performance. If you take advantage of enough non-Python libraries where speed is important (e.g Ogre for 3D), and make use of Psyco, you should be able to do anything with reasonable performance requirements... what were you thinking of?

For game development strategies, I think this is probably not the best forum for such a question. There are sites devoted to game development that would probably give you more accurate and relevant information.

vharishankar 07-28-2006 06:38 AM

By "serious" I meant graphic-intensive and action-oriented games.

I tried using pygame and somehow I can never get used to python's object orientedness as opposed to C++. Maybe I'm too much into C++, but I find C++ classes far easier and more logical to use than python classes. Maybe it's the syntax.

Mind you, python looks very, very powerful and promising, but it's syntax to me is always a bit odd. I'm always ending my lines with a semicolon. And I'm not comfortable with how functions are called like this - for instance pygame.Class1.function(). To me I always feel that it's the object which should call the function and not the class.

Anyway, I guess if I do game programming on Linux, I'd choose SDL and C++. The only big problem is getting a good core engine for SDL in C++ going. Right now I'm hoping for any higher level game development library in C++/Linux which uses SDL (2d is ok, I am not looking for a 3d engine).

Hko 07-28-2006 09:39 AM

Quote:

Originally Posted by Harishankar
And I'm not comfortable with how functions are called like this - for instance pygame.Class1.function(). To me I always feel that it's the object which should call the function and not the class.

I think that is not really different in python than it is in C++.

In python you normally call a method (or "member function") on an object, not a class. It is however possible to call to do "Class1.function()". But this concept of a "class function" also exists in C++.

IIRC, the equivalent call for python's "Class1.function()" in C++ is: "Class1::function()".

CroMagnon 07-28-2006 03:05 PM

Quote:

And I'm not comfortable with how functions are called like this - for instance pygame.Class1.function(). To me I always feel that it's the object which should call the function and not the class.
I'm not sure where you got the idea that this was having to use classes to call methods... it is subdivision of namespaces, like C# uses (System, System.Windows, System.Windows.Forms...). For example, the display functions are in a submodule of the overall pygame module. If you want to access the functions after only importing pygame, you have to do this:
pygame.display.set_mode(res)
because set_mode is in a file called display.py (or .pyd) under the pygame directory.

If this bothers you, you could do this instead:

from pygame import display

and then call display functions directly:

display.init()
display.set_mode(res)

vharishankar 07-29-2006 12:46 AM

Ah ok. Thanks for that info. Maybe the dot confused me. I know we can call static member functions or functions in namespaces like Class1::method1() in C++. But the usage is different and we don't use the same separator. Using the dot for everything something does confuse.

vharishankar 07-29-2006 08:17 AM

I'm going back to SDL C/C++ at the moment. Not that I can do a lot with that either. I'm just learning SDL but I don't want to confuse the pygame aspects of SDL with the SDL API itself.

SDL itself seems far far easier to learn than the monster DirectX, so I guess using its logical structure building a basic game using it should be fairly easy.


All times are GMT -5. The time now is 09:10 AM.