Creating a Game in Python Using PyGame – Part One
Prerequisites
In order to follow along with this tutorial you will need Python 2.4 and PyGame 1.7.0+ installed. Since I’m doing this all on a Mac and Python 2.4.2 is not available from MacPython or any other site as a disk image I decided to install from source.
If you are try to build Python on a Mac as well you should probably install into the /Library/Frameworks path as explained by this site.
Basically once you have downloaded the source from python.org unpack the tar ball as follows:
tar -zxvf Python-2.4.2.tgz
Once that has finished change to the Python-2.4.2 directory that was just created and install it by issuing the following commands:
./configure --enable-framework
make
sudo make frameworkinstall
For Windows or Linux you should be able to install easily given the instructions on the Python site.
This will install Python in the /Library/Frameworks path, and create a symlink to the python executable in /use/local/bin, which is not part of the PATH environment variable on new OS X builds, so you will probably want to add it:
export PATH=/usr/local/bin:$PATH
Part One
The full source of this tutorial can be downloaded here.
So let’s actually start creating this game using PyGame. For our snake image in the game I’m going to use the snake to the left for now. As you can see I’m not artist, but I was able to install the gimp on my Mac and get that image to a point that I think is relatively acceptable. If anyone out there has any graphics skills and can whip me up a better looking python in a 64×64 png I’d gladly use it!
So the first thing we are going to do is create a new PyDev project in Eclipse. I’m going to use Python 2.4 for this project because it is the version that is compatible with my PyGame Installation.
Then I’m going to create a new file called PyMan.py, this will be the main file of our game for now. The architecture may change as I go through this and discover better ways to use the files in my projects but for now this will work as a main file. In the directory that I create my project I will also create a subfolder entitled “data” and in that subfolder I will have another folder entitled “images” where I will store the above snake.png image.
Note: A lot of the information in this post was taken from the Pete Shinner’s great Line by Line Chimp and Python Pygame Introduction tutorials.
Now the first thing that we are going to have to do is import the libraries that we are going to need, we’ll also warn the user if the font or sound mixers are not available:
import os, sys import pygame from pygame.locals import * if not pygame.font: print 'Warning, fonts disabled' if not pygame.mixer: print 'Warning, sound disabled'
Then we’re going to create a class called PyManMain, this is going to be the main class of our game, it will handle all of the main functions in our game, things like the game loop, the screen creation, and keeping track of all of our sprites:
class PyManMain: """The Main PyMan Class - This class handles the main initialization and creating of the Game.""" def __init__(self, width=640,height=480): """Initialize""" """Initialize PyGame""" pygame.init() """Set the window Size""" self.width = width self.height = height """Create the Screen""" self.screen = pygame.display.set_mode((self.width , self.height))
As you can see our __init__ function takes two optional parameters height and width, this will be the height and the width of the screen that we create. The __init__ function basically initializes pygame (pygame.init()) and then creates our main screen using the pygame.display.set_mode function.
So far so good! The next thing that we are going to need is a game loop, this is the loop that will process all of the events that PyGame sends our way. To do that, we’re going to add a function to our PyManMain class called MainLoop:
def MainLoop(self): """This is the Main Loop of the Game""" while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit()
We’ll also add the code to our class that will start out game:
if __name__ == "__main__": MainWindow = PyManMain() MainWindow.MainLoop()
If you run this now you will be with a very uninspiring black screen. It may not be much but for the amount of code that we’ve written it’s pretty good.
The next thing that we need to create is out snake sprite. We are going to wrap our snake sprite in it’s own class called snake (of course) and it will be based off of the pygame.sprite.Sprite class. If you want to read more about PyGames sprite and group classes you should read piman’s great sprite tutorial:
class Snake(pygame.sprite.Sprite): """This is our snake that will move around the screen""" def __init__(self): pygame.sprite.Sprite.__init__(self) self.image, self.rect = load_image('snake.png',-1) self.pellets = 0
As you can see the Snake class really isn’t doing much besides initializing the Sprite base class and loading the snake image. It also sets pellets to zero, this variable isn’t used yet but it is the number of pellets that our snake has eaten.
You’ll notice that we use load_image to load our snake image. This function is taken from the Line by Line Chimp tutorial. I created a new file for my project called helpers.py which will contain all helper functions. I put load_image in this file and added the following to the top of PyMan.py:
from helpers import *
Now we have to create an instance of our snake sprite and display it. To do this I created another function in the PyManMain class called LoadSprites, this function will take care of loading all of our sprites:
def LoadSprites(self): """Load the sprites that we need""" self.snake = Snake() self.snake_sprites = pygame.sprite.RenderPlain((self.snake))
This function creates the sprite (self.snake = Snake) and then creates a group that contains our snake sprite (self.snake_sprites = pygame.sprite.RenderPlain((self.snake))).
We are also going to have to make some changes to the MainLoop function, we are going to have to load all of our sprites before we enter the while loop:
"""Load All of our Sprites""" self.LoadSprites();
Then after our event for loop but within the while loop we need to tell PyGame to draw our sprit:
self.snake_sprites.draw(self.screen) pygame.display.flip()
Now we’re getting somewhere! We’ve got our little PyMan snake displaying himself in the top left corner of our screen. Not too bad.
The next thing that we’re going to want to do is create and display all of our pellets, this isn’t very difficult if you understood the snake sprite above you’ll understand this:
class Pellet(pygame.sprite.Sprite): def __init__(self, rect=None): pygame.sprite.Sprite.__init__(self) self.image, self.rect = load_image('pellet.png',-1) if rect != None: self.rect = rect
The only difference you’ll see in the pellet class is the fact that we have an optional rect parameter, which lets us place the pellet where ever we want. The pellets I’ve created aren’t the best pellets that I’ve ever seen but just like the snake.png they’ll do for this example.
We then need to load the pellet sprites in our LoadSprites function:
"""figure out how many pellets we can display""" nNumHorizontal = int(self.width/64) nNumVertical = int(self.height/64) """Create the Pellet group""" self.pellet_sprites = pygame.sprite.Group() """Create all of the pellets and add them to the pellet_sprites group""" for x in range(nNumHorizontal): for y in range(nNumVertical): self.pellet_sprites.add(Pellet(pygame.Rect(x*64, y*64, 64, 64)))
Then we have to draw the pellets in out MainLoop:
self.pellet_sprites.draw(self.screen) self.snake_sprites.draw(self.screen) pygame.display.flip()
Now it’s time to make that snake move, to do so we’re going to have to look at the event loop in our MainLoop. ( for event in pygame.event.get():) What we are going to do is move the snake around when the arrow keys are pressed. To do that we are going to check to see if the event is a KEYDOWN event, and if it is a key down event whether the key being pressed is one of the arrow keys:
if event.type == pygame.QUIT: sys.exit() elif event.type == KEYDOWN: if ((event.key == K_RIGHT) or (event.key == K_LEFT) or (event.key == K_UP) or (event.key == K_DOWN)): self.snake.move(event.key)
Then we have to add a move function to our snake class that will actually move our snake:
def move(self, key): """Move your self in one of the 4 directions according to key""" """Key is the pyGame define for either up,down,left, or right key we will adjust ourselves in that direction""" xMove = 0; yMove = 0; if (key == K_RIGHT): xMove = self.x_dist elif (key == K_LEFT): xMove = -self.x_dist elif (key == K_UP): yMove = -self.y_dist elif (key == K_DOWN): yMove = self.y_dist self.rect.move_ip(xMove,yMove);
You’ll notice that the move function references self.x_dist and self.y_dist, these are basically two integers that I set in the snake’s __init__ function, they are the number of pixels that we want the snake to move in the x or y direction. I set mine to 5.
To move the snake we adjust it’s rect so that the next time it is displayed it will be drawn in a different direction. To do that we call the rect.move_ip function with the amount of pixels in the x and y directions to move.
Now we are going to have to add some collision detection to make our snake eat our pellets. Thankfully the spirt and group classes have built in collision detection that we are able to use:
"""Check for collision""" lstCols = pygame.sprite.spritecollide(self.snake , self.pellet_sprites , True) """Update the amount of pellets eaten""" self.snake.pellets = self.snake.pellets + len(lstCols)
We use the pygame.sprite.spritecollide function to see if our snake sprite collided with any of the pellet sprites. If they did we kill which ever pellet that was hit by passing True as the third parameter. pygame.sprite.spritecollide basically goes through all of the sprites in the group passes and sees if the sprites rect intersects with the sprit passed in as parameter one.
pygame.sprite.spritecollide also returns a list of all the sprites that were collided by our snake, so we use that to update the number of pellets that we have eaten.
The last thing that we our going to do in this tutorial is display the number of pellets that we have eaten to the user:
if pygame.font: font = pygame.font.Font(None, 36) text = font.render("Pellets %s" % self.snake.pellets , 1, (255, 0, 0)) textpos = text.get_rect(centerx=self.width/2) self.screen.blit(text, textpos)
This code is taken from the line by line chimp example with very few changes. Instead of telling the user to hit the chimp for cash, we’re telling them how many pellets that the snake has eaten so far. We need to put the code right right before we draw our sprites in the game loop.
That’s about it for this example, there is a bit of code in the finished “product” that I didn’t discuss but if you download the full source it the new code should be pretty self explanatory. Now this isn’t a full example by any means and probably isn’t something that you’d really want to base any game off of, but it does give you a pretty basic idea about what is required to create a game in using Python and PyGame.
If you are really interested in creating a game I’d suggest you download the full source and play around with it a bit. I’m also suggest (insist?) that you read the documentation and tutorials provided for you on the main PyGame site, if it wasn’t for them I would have been unable to write this simple tutorial.
Whew, that was a lot a typing, it’s time for me to go make some dinner and have a glass of wine.
Useful links:
If you like this post remember to digg it.
Note: Whew! Many thanks to James for finding the google cahce for me! I looked for it when I first deleted it but couldn’t fine it. Much appreciated!
Here are some alternate images that were sent to me by a kind reader named Jordan:





March 13th, 2006 at 6:28 pm
[...] Learning Python has a new tutorial up called Creating a Game in Python Using PyGame. It’s part one of a series, and looks really good. [...]
March 19th, 2006 at 4:27 pm
[...] learning python one man’s journey into python… « Creating a Game in Python Using PyGame – Part One [...]
March 28th, 2006 at 6:34 pm
Hey, about the rest of your post…
You should probably grab it from Google ASAP before they cache over it. If your too late, let me know, I’ve grabbed a copy from their cache.
link.
April 16th, 2006 at 5:37 pm
[...] All right in this section of the tutorial we are going to start adding the bad guys. If you are familiar with the changes that we made in part two it should be pretty clear to you how are are going to create these bad guys. If you haven’t already you should check out part one and part two. If you would like the full source and all of the images you can get it here. [...]
May 26th, 2006 at 9:19 pm
If you want a good python image, go to the adress below and scale it down to 64 x 64 in GIMP. It actually scales to 67 x 64 or 64 x 61 but from there just resize the window, a few pixels don’t the appearance in this case. That is if your allowed to legally I don’t really know how all of that works…
http://www.vanille.de/projects/python.spy
June 7th, 2006 at 1:08 pm
which plugin are you using for syntax highlighting in wordpress ?

selsine Says:June 7th, 2006 at 2:03 pm
Hey Izaac I’m using this plugin right now:
http://www.chroder.com/archives/2005/04/16/wordpress-codehighlight-plugin/
There are a bunch of other ones, but this one seemed to work the best for me.
June 8th, 2006 at 3:15 am
Hi!
First, thanks for the tutorial – it’s very clearly written, and very informative!
I have a question for you – I am using Mac as well, but I am stumbling upon a very odd problem: the images do not load!
When I download your example, and try to run pyman.py (with the Python Launcher 2.4, I get a return in Terminal that states:
“adm6-171:~ miguel$ “/Library/Frameworks/Python.framework/Versions/2.4/bin/python” “/Users/miguel/Desktop/PyMan/PyMan.py” && echo Exit status: $? && exit 1
Cannot load image: data/images/snake.png
Couldn’t open data/images/snake.png”
And that’s it. I am quite puzzled (and a newbie to OSX, and to programming in general).
Any clue about the reason?
I am running Python 2.4.3, Pygame 1.7.0 (with py2app, numeric, pyobjc and pyopengl), and OSX 10.4.6 on a PPC machine.
Thanks a lot for the help!
/miguel sicart

selsine Says:June 8th, 2006 at 10:11 am
Hi Miguel,
First thanks for the kind words about this tutorial!
If you have downloaded the zip file and unzipped all of its contents onto your desktop does the following file exist: “/Users/miguel/Desktop/PyMan/data/images/snake.png”?
I think that it’s a problem with the current directory when you use the Python Launcher. To fix the problem try replacing this code in the helpers.py load_image function:
With this:
June 12th, 2006 at 8:29 am
Hi Selsine,
Thanks for the help … but it does produce an error output:
“Traceback (most recent call last):
File “/Users/miguel/Desktop/PyMan/PyMan.py”, line 6, in ?
from helpers import *
File “/Users/miguel/Desktop/PyMan/helpers.py”, line 9
fullname = os.path.join(fullname, ‘data’)
^
SyntaxError: invalid syntax”
I am wondering, the code you suggested changing – what does it exactly do? So, what would be the problem at hand here? (sorry for the very newbie questions, and thanks a bunch for the help!)
cheers
/m

selsine Says:June 12th, 2006 at 10:11 am
Hi Miguel,
The problem basically has to do with the working directory and how the relative path to the images is getting resolved. It you were to start a terminal and then browse to the /Users/miguel/Desktop/PyMan/ directory and launch the program using: >python PyMan.py the problem shouldn’t happen because the working directory will be set properly.
The new code that I sent you is meant to create the full path to the images. I’m not sure why you are getting a syntax error as it’s working properly for me. Here is all of the code from my helpers file:
Don’t feel bad about asking questions!
July 29th, 2006 at 5:04 pm
in program:
import sys
from pygame import *
init()
size=width, height= 320,240
speed=[2,2]
black=0,0,0
screen = display.set_mode(size)
ball = image.load(”ball.bmp”)
ballrect = ball.get_rect()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
ballrect = ballrect.move(speed)
if ballrect.left width:
speed[0] = -speed[0]
if ballrect.top height:
speed[1] = -speed[1]
screen.fill(black)
screen.blit(ball, ballrect)
display.flip()
when I run this program, the following message apeears:
Traceback (most recent call last):
File “C:\Documents and Settings\GUILHERME\Desktop\game.py”, line 9, in ?
ball = image.load(”ball.bmp”)
error: Couldn’t open ball.bmp
which directory should be the file “ball.bmp”?

selsine Says:August 2nd, 2006 at 2:51 pm
Hi guiga,
ball.bmp should be in the same directory as your game.py file, you might want to look at the exmaple code that I created for Miguel, where I create the full path to a file.
August 3rd, 2006 at 3:48 pm
umm..i get a syntax error
>>> class PyManMain:
The Main PyMan Class – This class handles the main initialization and creating of the game.
SyntaxError: invalid syntax
and “Main”, in “The Main PyMan Class” is highlighted
why is this?

selsine Says:August 3rd, 2006 at 3:55 pm
Hi Kronos,
You have to make sure that everything is tabbed properly and that the comment is enclosed withing three quotes “”" i.e.:
Is that what your code looks like?
September 23rd, 2006 at 5:59 pm
all programs work as you said to download, but except eclipse. For example it doesn’t vairify “java runtime, or java VM.”
i went to FAQs and it was very confusing.
is there another kind of program thats like eclipse or eclipse?
PLEASE HELP ME THE SUSPENCE IS KILLING ME YOU DON’T KNOW HOW LONG I WANTED TO START MAKING VIDIO GAMES!?

selsine Says:September 26th, 2006 at 11:42 am
Hey Please Help Me,
What OS are you trying to run Eclipse on? Depending on your operating system you may have to make different decisions.
Also keep in mind that you don’t actually need to use Eclipse, you could use any text or python editor that you want.
October 17th, 2006 at 1:18 am
Selsine,
My only complaint here is that the proper usage of the pyDev Eclipse developement environment isn’t really addressed. You seem to mystically create a .py file outside of a package… etc. I managed to debug through the bitmap issue after using the pyDev debugger… Good work in general and cheers for your efforts.

selsine Says:October 17th, 2006 at 12:03 pm
Hi Oscar,
You’re right I didn’t go into too much detail on using PyDev and Eclipse, some of that is because it’s not necessary to use those tools and you can get by just fine with a simple text editor if you choose. But perhaps it would be a good idea to outline some of the inner-workings of PyDev and Eclipse in a separate tutorial.
I’m also not sure what you mean when you say that I “seem to mystically create a .py file outside of a package”? As far as I remember I selected File | New | File in Eclipse to create new *.py files, I haven’t been using Eclipse lately so my memory is a bit fuzzy.
Now as far as the whole package thing is concerned, I assume that you are referring to Python packages? If so then yes I didn’t use a package since all of the files are located in the same directories you can simply import them with the “Import” command.
If I’ve misunderstood what you mean please let me know, and I’ll try to improve the tutorial so that future users do not run into the same problems.
October 22nd, 2006 at 7:53 pm
I think it is a neat program and I would love to use it
December 4th, 2006 at 9:19 am
the problem is
When I press the right-arrow button and hold it, the snake will move right.
Then I press the down-arrow button and hold it without release right-arrow button, the snake will move down.
Then I release the right-arrow button ,the snake is stopped moving even the down-arrow button is still holded.(It should continue moving down.)
How can i fix it.
December 12th, 2006 at 6:30 pm
Abby,
this is covered in part 2 of this (pretty cool) tutorial. You need to look at the key up event as well as the key down event.

selsine Says:December 12th, 2006 at 8:51 pm
NKT,
Thanks for answering Abby’s question! Much appreciated!
December 13th, 2006 at 8:27 pm
im using the included IDLE with python 2.4, and have checked the code several times now, however, i keep getting this same msg
————————————————————————————-
Traceback (most recent call last):
File “C:/Program Files/Python 2.4/PyMan.py”, line 8, in -toplevel-
class PyManMain:
File “C:/Program Files/Python 2.4/PyMan.py”, line 27, in PyManMain
MainWindow = PyManMain()
NameError: name ‘PyManMain’ is not defined
————————————————————————————–
this is my code
import os, sys
import pygame
from pygame.locals import *
if not pygame.font: print ‘warning fonts disabled’
if not pygame.mixer: print ‘warning sound disabled’
class PyManMain:
“”"main game class”"”
def __init__(self, width=640, height=480):
“”"initialize”"”
“”"initialize PyGame”"”
pygame.init()
“”"set the window size”"”
self.width = width
self.height = height
“”"create the screen”"”
self.screen = pygame.display.set_mode((self.width, self.height))
def MainLoop(self):
“”"this is the main game loop”"”
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if __name__ == “__main__”:
MainWindow = PyManMain()
MainWindow.MainLoop()
December 13th, 2006 at 8:27 pm
gah, the spacing got messed up, but the tabulation is correct

selsine Says:December 13th, 2006 at 8:37 pm
Hi Kevin, looking at what you posted (not what showed up here) I can see the tabs, and the problem is that you have the last if block tabbed to be a member of the class:
When it should actuallly be:
Since the if block is supposed to be located outsite of the class.
December 13th, 2006 at 9:17 pm
ah cool, thanks selsine
February 20th, 2007 at 10:30 pm
Hey, I’m new to programming in Python, and I just have a simple question: the artwork that you put into python with bitmap(bmp) or .png files, how do you get rid of the extra color behind the picture? say for instance, I am using Gimp(which I am), how do I get rid of the extra white behind the picture? When I put an image into my game that I have made with gimp, it shows the extra area that I didn’t edit, so when my picture shows up in the game, it looks like a man with a white box around it. Any way I can get rid of that?

selsine Says:February 21st, 2007 at 10:10 am
Hi DbOyLeOn,
Take a look at the surface.set_colorkey function. It’s what you need to call in order to make the while around your character transparent.
Actually it will make all the while in your image transparent, which is why people often use that terrible pink colour that I used as their background colour since it isn’t likely to appear in the rest of their image.
Take a look at the load_image function works:
If not passed the transparent colour key it tries to get it from the top left corner of the image.
I hope this helps.
February 21st, 2007 at 6:36 pm
What do I have to edit into the load_image function to make the pink color transparent?
February 22nd, 2007 at 10:32 pm
Thanks selsine this helped alot, it didn’t help directly, but I like a challenge. I didn’t work when I took this code and put it into my program, but I played around with it for a few hours, and it all fell into place. Since I want some hands on experience anyway, I’m actually glad it didn’t work right off. Thanks again.

selsine Says:March 3rd, 2007 at 2:01 pm
Hi DbOyLeOn,
Sorry I couldn’t get back to you any earlier I was on a short little trip. It’s also too bad that the code didn’t work for you, it may be because you didn’t have your transparent colour in the top left pixel?
Either way I’m glad that you were able to figure it out, if you know what the problem was perhaps you could post it here so that it may help some other people in the future.
Good luck with PyGame!
April 14th, 2007 at 1:40 pm
Thanks to Selsine source code, Now it works for me
April 27th, 2007 at 11:03 am
Hi. I seem to be having a major problem with PyGame. I’m no wiz at computers, but I’m using a Dell with python 2.4 and pygame 1.7, yet pygame doesn’t seem to work right. I can get the blank PyGame window to come up, but once I add sprites or anything, and do everything I can to get rid of all the errors, it just closes when I run it! What’s even stranger is some pygame things I download will work, while others(Like the line by line chimp) will just close the instant I try to run them! If you have any idea of what might be going on, I would be very grateful! Thanks!

selsine Says:April 29th, 2007 at 3:03 pm
Hi JoeBob,
How are you running the python script? If you are not running it from the windows command line, run it from there and see if there is anything (i.e. and error) that is printed out when you run it.
Hopefully that information will let us know what the problem is.
May 2nd, 2007 at 3:28 pm
I’m sorry, but all it does is instantly close. I’ve gotten one thing to work: The Sprite tutorial, with the boxes. For the most part, that’s it. Everything else, if it has no errors, will just pull up the pygame window, wait a millisecond, and then close! I don’t know if there’s anything else I should download or anything, but I would if it could fix the problem. If there is anything, I’d try it! Thanks!

selsine Says:May 5th, 2007 at 10:55 am
Hmm, so you don’t get any error messages when you run it from the commandline?
Well then I would suggest adding some debug print messages to the code. For example:
And in perhaps a few other places. Then when you run from the command line, what the program spits out should let us know how far the execution is going and perhaps why it isn’t working.
June 29th, 2007 at 5:23 am
THis tutorial is great!! I have learnt a lot with it! Thanks for writing it!! I have a question about loading images : I cant load any image. i tried ur path programme-doesnt work, i tried other programs-doesnt work. pls help i tried all kind of formats, but it allways say:Couldnt open image. pls help

selsine Says:July 6th, 2007 at 9:45 am
Hi Potte,
What OS are you running on? How are you launching your pythong applicaction? Can you load any files?
What happens if you try replacing the load_image function with the following? Does it work? What gets printed out?
July 30th, 2007 at 10:08 am
Hi!
it says global name ‘__file__’ is not defined,though i only tried importing sys and os.
All the books say that the pic and the prog should be in the current directory,but in doesnt work for me on win xp.
Also when i try running a script (with the if __name__=’__main__’:)by double-clicking on it, a black window pops up and disappears again. I tried putting raw_input at the end, but it doesnt work
And for ur quetions: i use win xp , i tried launching it by double-clicking,importing,or running it in the shell , yes, as far as i can remember once i loaded a textfie,i can import and save with no problem. i really dont know what to do know , i read severla books on the issue, but i cant find the problem
potte

selsine Says:September 23rd, 2007 at 10:09 am
Hi Potte,
What version of Python are you using? The __file__ attribute was introduced in version 2.2 or 2.3 I believe.
Did you try this version of the function:
November 25th, 2007 at 7:53 pm
hey man
just wan to thank you for this post. I had no clue of pygames 4 days back and today i am done creating a cool soccer game with 3 players . your tutorial gave a great start and now i am done with my project!!! wooooh!!!! thanks again
February 9th, 2008 at 4:03 pm
Simple, but nice coding. What about using some AI and place 2 or 3 enemies.
May 23rd, 2008 at 9:28 pm
where do you add self.LoadSprites();
it doesnt load the snake image!
thnx
July 28th, 2008 at 12:36 pm
[dude@localhost Game]$ python PyMan.py
Traceback (most recent call last):
File “PyMan.py”, line 25, in
MainWindow.MainLoop()
AttributeError: PyManMain instance has no attribute ‘MainLoop’
[dude@localhost Game]$
Help?
August 26th, 2008 at 6:02 am
Great way to learn the basics of Python. Thanks!
September 22nd, 2008 at 5:33 pm
[...] por un buen blog sobre Python (que está en inglés, lamentablemente), encontré un interesante tutorial, sobre como hacer un juego (muy muy básico, aparentemente) con Python y [...]
December 15th, 2008 at 2:57 am
Hey, I found a great python sprite (okay well maybe its a cobra) here:
http://sdb.drshnaps.com/sheets/Misc/Misc/Mobile/PuzzleWorld2.png
January 16th, 2009 at 5:36 am
thanx man that helped alot
January 18th, 2009 at 12:00 pm
[...] window is not closing, tut not helping im doing this : http://www.learningpython.com/2006/0…game-part-one/ and when closing the program the window stays up and doesnt respond. i tried adding this: [...]
February 22nd, 2009 at 2:34 am
I just want to say thank you! A great tutorial….nice work. Finally a tutorial which explains things to me in human language so that even I can understand it
Keep up the good work!!
March 29th, 2009 at 8:45 pm
[...] Introduction and Part One [...]
August 20th, 2009 at 7:29 am
when i try to load the system i get a black screen and an error called: cannot open /data/images/snake.png!
October 28th, 2009 at 3:00 pm
[...] Creating a Game in Python using Pygame Good tutorial with rich code examples. [...]
November 9th, 2009 at 1:58 pm
thanks for the tut. i m a newbee to python, today is my first day with python environment. i just run ur tut and is working fine (windows XP with Python 2.5). just it gets crashed when i close(don’t understand, will know soon). anyway thank u for the tut.
January 31st, 2010 at 5:17 pm
Hey man, first i wanna congratulate you for the tutorial. I have managed to learn a lot but i still have a few doubts and im wondering if you could help me with then.
The major one is that, with that kind of movement sometimes the snake aint into the propper position to go into the pellets way you know, so i have to go back and forth to adjust it into the right position to so i can turn to the desire position. Im not sure if im explaining it propperly. So, is it possible for me to make the snake move exactly one block for each movement? Instead of a free movement to any desire position? That would solve the problem im having.
Thanks for the tutorial and i would appreciate if you could help me out.
February 18th, 2010 at 5:25 pm
[...] original code from was learningpython.com (not 100% sure) and the following links to the tutorials: Tutorial 1 Tutorial 2 Tutorial [...]