Creating Games with Pygame
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
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
| 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 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- The Pari Package On Linux
- New Products
- New Products
- Home, My Backup Data Center
- This is the easiest tutorial
3 hours 59 min ago - Ahh, the Koolaid.
9 hours 38 min ago - git-annex assistant
15 hours 37 min ago - direct cable connection
16 hours 24 sec ago - Agreed on AirDroid. With my
16 hours 10 min ago - I just learned this
16 hours 14 min ago - enterprise
16 hours 44 min ago - not living upto the mobile revolution
19 hours 36 min ago - Deceptive Advertising and
20 hours 11 min ago - Let\'s declare that you have
20 hours 12 min ago
Enter to Win an Adafruit Prototyping Pi Plate 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 Prototyping Pi Plate 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
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.



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.