Creating Games with Pygame
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- I once had a better way I
2 hours 56 min ago - Not only you I too assumed
3 hours 14 min ago - another very interesting
5 hours 7 min ago - Reply to comment | Linux Journal
7 hours 44 sec ago - Reply to comment | Linux Journal
13 hours 54 min ago - Reply to comment | Linux Journal
14 hours 10 min ago - Favorite (and easily brute-forced) pw's
16 hours 2 min ago - Have you tried Boxen? It's a
21 hours 54 min ago - seo services in india
1 day 2 hours ago - For KDE install kio-mtp
1 day 2 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
Seems Python really sucks for
Seems Python really sucks for programming! This is the forth piece of code I've copied to try and run and it came up with errors etc like the other posters stated. Its either platform dependent, ie Linux stuff, or it has things that need to be installed to make a game or program to run. This makes it extremely frustrating for anyone new to programming to actually get anything other than hello world to run!
Interestingly I've not had this problem with any of the java listings I've found, so it looks like I'll be going the Java route after all.
You shouldn't be trying to do
You shouldn't be trying to do anything with graphics unless you are comfortable with a language, you need to have all the basics in order to understand what you are doing.
Python is way simpler than Java to learn, btw. Just get a book if you have trouble googling for tutorials.
Hey
Great stuff! Python is an awesome language to program in, and pygame is very good to beginners. I've started my own set of tutorials on my site : http://lameness-prevails.com/
Check it out and let me know if you like it!
Re: Creating Games with Pygame
Thanks for the article! It's really helpful.
NameError: name 'main' is not defined
Traceback (most recent call last):
File "Pygame_LinuxJournalExample.py", line 23, in
if __name__ == '__main__': main()
NameError: name 'main' is not defined
this appeared after trying to fix lots of indentation errors...
complex, difficult and confusing
For newbies, this article is complex, difficult and confusing - and plenty of redundancies...
Would be much more easier to learn from minimal examples.
I have some similar minimal examples at:
http://nitrofurano.linuxkafe.com/python
http://nitrofurano.linuxkafe.com/sdlbasic
http://nitrofurano.linuxkafe.com/wxbasic
FTP Link
Hi,
The file is here:
ftp://ftp.ssc.com/pub/lj/listings/Web/7694.tar.gz
("Web", not "WEB")
You could have found it yourself on the ftp server... ;-)
Dead Link
Hi people,
Looks like the link is dead. Can someone else give it a try?
ftp://ftp.ssc.com/pub/lj/listings/Web/7694.tar.gz
Thanks,
Jim
The link
The link still doesn't work with that 'Web'.
Re: Creating Games with Pygame
Actually the link to the tarball is STILL not working- can anyone get a hold of it and mail it to mr981505@netscape.net
ta.
Re: Creating Games with Pygame
Excellent.
Now, if we could have a similar article detailing a simple database app (PostgreSQL, MySQL or similar as the back end) with a gui front end I would seriously consider spending time on Python.
Re: Creating Games with Pygame
Database connection is really easy in python. For Dbase connectivity you can find information on http://www.python.org/topics/database/. With the DB API 2.0, there is actually not much difference in connecting to a mysql, or a postgresql database.
For gui, you have a number of choices - wxpython, tk, gtk just to name a few. You can find info on this on www.wxpython.org . If you prefer tk, you can find info on that on http://www.python.org/topics/tkinter/.
Re: Creating Games with Pygame
Instead of waiting for next article look at http://www.pygtk.org/pygtk2tutorial/index.html
Greetings
kamyl
Re: Creating Games with Pygame
Very nice tutorial, i've never programmed in Python and I was able to understand a lot and even find some problems
This is mostly logic but...
in the load_sound method there's a mistake
fullname = os.path.join('data', name)
if os.path.exists(full_name) == False: # Wrong
sound = pygame.mixer.Sound(fullname)
else:
print 'File does not exist:', fullname
return No_Sound
Change the mistake for
if os.path.exists(full_name) == True:
and then it'll work :) if it exists it should be played and not the oposite :)
Congratulations for this nice tutorial
Re: Creating Games with Pygame
Also the author confuses 'fullname' and 'full_name'.
This article is very poorly written.
Re: Creating Games with Pygame
There is no error in the actual source file
Re: Creating Games with Pygame
That the tutorial deviates from the source it's explaining is another serious problem.
program coding ex. color
how to create it using the ,
Re: Creating Games with Pygame
The programming in the tutorial certainly had some problems, but the introduction to the topic was top notch. I was introduced to an aspect of python programming (well, programming in general) I had never been exposed to in such a way that I felt I had a handle on the basics. Sure, the sample code could have been editted better, but the tutorial served it's purpose in introducing a new package and showing off the capabilities.
Re: Creating Games with Pygame
Even better would be just "if os.path.exists(fullname):"; usually in Python there's no guarantee that the result will be True or False, just that the result will evaluate to true or false in a boolean context (which True and False happen to do, but so do 1 and 0, or 18 and None...)
Re: Creating Games with Pygame
Just a few nitpicks from a Pygame hacker...
RenderClear is "going away" in Pygame 1.7, coming in a few days. Group, RenderPlain, and RenderClear are now all the same group. The fourth one, RenderUpdates (not mentioned in the article), is still separate and usually gives better performance when used properly (and doesn't require double buffering).
You mention that pygame.time.delay with a constant value might be too long for slower machines; that's what pygame.time.Clock is for, you can specify an FPS to try and maintain, and it will calculate the correct time to sleep.
The call to random.seed() is not necessary; Python automatically seeds the RNG when it is not done explicitly.
Resetting the screen mode can be avoided by calling pygame.quit() at the end of the program. This shuts down all the SDL systems, including the display.
"if enemyship_sprites.sprites() == []:" is unsafe Python code in general. You don't know if sprites() is going to return a list, tuple, iterator, generator... Properly it should be written as "if len(enemyship_sprites.sprites()) == 0:", but you can also write it as "if not enemyship_sprites:" (I don't like that version). Pygame 1.7 you can just write "if len(enemyship_sprites) == 0:" which is probably the best way in the future.
-- Joe Wreschnig
not bad
Not bad but I've seen better tutorials on pygame. Anyway, good python coder can do all of available tutorials in a week... Not much of it so good work!
--
Regards
Nazgob
www.nazgob.com
Re: Creating Games with Pygame
The link to the tar ball on the LJ FTP site has been fixed.--LJ Editorial
Uh... no. The link is still b
Uh... no. The link is still broken. However, the user comment above with the correct URL does work.
Re: Creating Games with Pygame
The link to the source code and image files gives an ftp error:
"550 Can't chagne director to /pub/lj/listings/WEB/7694.tar.gz: No such file or directory"
Otherwise looks like it could be fun to play around with.