The Ur-Quan Masters Discussion Forum

The Ur-Quan Masters Re-Release => Starbase Café => Topic started by: countchocula86 on February 08, 2007, 08:22:28 pm



Title: Python/Pygame
Post by: countchocula86 on February 08, 2007, 08:22:28 pm
I was just curious if anyone here had a good a knowledge of python/pygame or knows a good tutorial. I've never coded in anything before lol, but I'm curious (I kinda wanna make some shmups) and I was told python was the best combination of powerful/easy-to-learn.
I find, though, I'm having trouble with the 'module' concept, like how to import modules from pygame...and what the modules even do, etc.


Title: Re: Python/Pygame
Post by: youBastrd on February 09, 2007, 09:25:56 pm
Python with PyGame is a pretty powerful combination.  It might be a little sharp of a learning curve to start with it right away.  Try it first, you might pick it up and love it.  If not, you might prefer something visual like Torque or Flash for your first language. 

The module concept is common to most programming languages.  The idea is that whenever possible, you should choose to reuse existing, tested, working, elegant code.  Some code is designed and written specifically for this purpose: those are called modules, or libraries.  Every language will have its own built in libraries, and most modern languages have large numbers of capable libraries.  The big idea from a programmer's point of view when using this libraries is that you can do everything you want much faster.  You don't have to, say, write software to examine a PC's video card, choose a operating system level driver, etc.  Instead, you just say "import PyGame" and it'll handle all that for you.  I'm not explaining this very well, just check out the 'pedia entry (http://en.wikipedia.org/wiki/Software_library). :)


So here are some examples of such modules:
PyOpenGL (3D graphics)
PyGame (lots of gaming stuff wrapped together in a neat little package)
SDL (2D Graphics + input routines and lots more), SDL_mixer (sound effects etc)
PyODE (an open source physics engine)
There's probably ones for Ogg support and just about everything else you might need.  Dig around a little. :)

In Python, it's much easier to get started with these modules than other languages.  The idea is that you install the modules once on your PC via a setup.exe-type thing, then you only have to say "import pygame" to get access to all the functions and data structures from pygame.  Python "knows" where to find the library and what to do with it once it has been installed on your PC.  This is a much simpler process than in other languages.  That alone empowers you to do things quickly.  Python insulates you from a lot of the details like compiling libraries, and linking to them, and including headers and must be done in C or C++. 

Best of luck, hope that made a little sense at least  :)