<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Creating a Game in Python Using PyGame - Part One</title>
	<atom:link href="http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/</link>
	<description>one man's journey into python...</description>
	<pubDate>Sun, 06 Jul 2008 23:26:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>By: B</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-85650</link>
		<dc:creator>B</dc:creator>
		<pubDate>Sat, 24 May 2008 02:28:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-85650</guid>
		<description>where do you add        self.LoadSprites(); 
it doesnt load the snake image!
thnx</description>
		<content:encoded><![CDATA[<p>where do you add        self.LoadSprites();<br />
it doesnt load the snake image!<br />
thnx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TheRazor</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-61112</link>
		<dc:creator>TheRazor</dc:creator>
		<pubDate>Sat, 09 Feb 2008 21:03:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-61112</guid>
		<description>Simple, but nice coding. What about using some AI and place 2 or 3 enemies.</description>
		<content:encoded><![CDATA[<p>Simple, but nice coding. What about using some AI and place 2 or 3 enemies.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madan</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-53763</link>
		<dc:creator>madan</dc:creator>
		<pubDate>Mon, 26 Nov 2007 00:53:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-53763</guid>
		<description>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</description>
		<content:encoded><![CDATA[<p>hey man</p>
<p>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</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: selsine</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-46756</link>
		<dc:creator>selsine</dc:creator>
		<pubDate>Sun, 23 Sep 2007 15:09:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-46756</guid>
		<description>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:

[code lang="python"]
def load_image(name, colorkey=None):

	fullname = os.path.dirname(sys.argv[0])
	fullname = os.path.join(fullname, 'data')
	fullname = os.path.join(fullname, 'images')
	fullname = os.path.join(fullname, name)
	try:
		image = pygame.image.load(fullname)
	except pygame.error, message:
		print 'Cannot load image:', fullname
		raise SystemExit, message
	image = image.convert()
	if colorkey is not None:
		if colorkey is -1:
			colorkey = image.get_at((0,0))
		image.set_colorkey(colorkey, RLEACCEL)
	
	return image, image.get_rect()
[/code]</description>
		<content:encoded><![CDATA[<p>Hi Potte,</p>
<p>What version of Python are you using? The __file__ attribute was introduced in version 2.2 or 2.3 I believe.</p>
<p>Did you try this version of the function:</p>
<div class="hl-surround" ><div class="hl-main"><pre><span class="hl-reserved">def </span><span class="hl-identifier">load_image</span><span class="hl-brackets">(</span><span class="hl-identifier">name</span><span class="hl-code">, </span><span class="hl-identifier">colorkey</span><span class="hl-code">=</span><span class="hl-reserved">None</span><span class="hl-brackets">)</span><span class="hl-default">:

	</span><span class="hl-identifier">fullname</span><span class="hl-default"> = </span><span class="hl-identifier">os</span><span class="hl-default">.</span><span class="hl-identifier">path</span><span class="hl-default">.</span><span class="hl-identifier">dirname</span><span class="hl-brackets">(</span><span class="hl-identifier">sys</span><span class="hl-code">.</span><span class="hl-identifier">argv</span><span class="hl-brackets">[</span><span class="hl-number">0</span><span class="hl-brackets">])
	</span><span class="hl-identifier">fullname</span><span class="hl-default"> = </span><span class="hl-identifier">os</span><span class="hl-default">.</span><span class="hl-identifier">path</span><span class="hl-default">.</span><span class="hl-identifier">join</span><span class="hl-brackets">(</span><span class="hl-identifier">fullname</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">data</span><span class="hl-quotes">'</span><span class="hl-brackets">)
	</span><span class="hl-identifier">fullname</span><span class="hl-default"> = </span><span class="hl-identifier">os</span><span class="hl-default">.</span><span class="hl-identifier">path</span><span class="hl-default">.</span><span class="hl-identifier">join</span><span class="hl-brackets">(</span><span class="hl-identifier">fullname</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">images</span><span class="hl-quotes">'</span><span class="hl-brackets">)
	</span><span class="hl-identifier">fullname</span><span class="hl-default"> = </span><span class="hl-identifier">os</span><span class="hl-default">.</span><span class="hl-identifier">path</span><span class="hl-default">.</span><span class="hl-identifier">join</span><span class="hl-brackets">(</span><span class="hl-identifier">fullname</span><span class="hl-code">, </span><span class="hl-identifier">name</span><span class="hl-brackets">)
	</span><span class="hl-reserved">try</span><span class="hl-default">:
		</span><span class="hl-identifier">image</span><span class="hl-default"> = </span><span class="hl-identifier">pygame</span><span class="hl-default">.</span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">load</span><span class="hl-brackets">(</span><span class="hl-identifier">fullname</span><span class="hl-brackets">)
	</span><span class="hl-reserved">except </span><span class="hl-identifier">pygame</span><span class="hl-default">.</span><span class="hl-identifier">error</span><span class="hl-default">, </span><span class="hl-identifier">message</span><span class="hl-default">:
		</span><span class="hl-reserved">print </span><span class="hl-quotes">'</span><span class="hl-string">Cannot load image:</span><span class="hl-quotes">'</span><span class="hl-default">, </span><span class="hl-identifier">fullname
		</span><span class="hl-reserved">raise SystemExit</span><span class="hl-default">, </span><span class="hl-identifier">message
	image</span><span class="hl-default"> = </span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">convert</span><span class="hl-brackets">()
	</span><span class="hl-reserved">if </span><span class="hl-identifier">colorkey </span><span class="hl-reserved">is not None</span><span class="hl-default">:
		</span><span class="hl-reserved">if </span><span class="hl-identifier">colorkey </span><span class="hl-reserved">is</span><span class="hl-default"> -</span><span class="hl-number">1</span><span class="hl-default">:
			</span><span class="hl-identifier">colorkey</span><span class="hl-default"> = </span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">get_at</span><span class="hl-brackets">((</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-brackets">))
		</span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">set_colorkey</span><span class="hl-brackets">(</span><span class="hl-identifier">colorkey</span><span class="hl-code">, </span><span class="hl-identifier">RLEACCEL</span><span class="hl-brackets">)
	
	</span><span class="hl-reserved">return </span><span class="hl-identifier">image</span><span class="hl-default">, </span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">get_rect</span><span class="hl-brackets">()</span></pre></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: potte</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-39177</link>
		<dc:creator>potte</dc:creator>
		<pubDate>Mon, 30 Jul 2007 15:08:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-39177</guid>
		<description>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</description>
		<content:encoded><![CDATA[<p>Hi!<br />
it says global name &#8216;__file__&#8217; is not defined,though i only tried importing sys and os.<br />
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.<br />
Also when i try running a script (with the if __name__=&#8217;__main__&#8217;:)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<br />
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<br />
potte</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: selsine</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-36275</link>
		<dc:creator>selsine</dc:creator>
		<pubDate>Fri, 06 Jul 2007 14:45:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-36275</guid>
		<description>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?

[code lang="python"]
def load_image(name, colorkey=None):

	fullname = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data'))
	fullname = os.path.join(fullname, 'images')
	fullname = os.path.join(fullname, name)
	print fullname
	try:
		image = pygame.image.load(fullname)
	except pygame.error, message:
		print 'Cannot load image:', fullname
		raise SystemExit, message
	image = image.convert()
	if colorkey is not None:
		if colorkey is -1:
			colorkey = image.get_at((0,0))
		image.set_colorkey(colorkey, RLEACCEL)
	
	return image, image.get_rect()
[/code]</description>
		<content:encoded><![CDATA[<p>Hi Potte,</p>
<p>What OS are you running on?  How are you launching your pythong applicaction?  Can you load any files?</p>
<p>What happens if you try replacing the  load_image function with the following?  Does it work?  What gets printed out?</p>
<div class="hl-surround" ><div class="hl-main"><pre><span class="hl-reserved">def </span><span class="hl-identifier">load_image</span><span class="hl-brackets">(</span><span class="hl-identifier">name</span><span class="hl-code">, </span><span class="hl-identifier">colorkey</span><span class="hl-code">=</span><span class="hl-reserved">None</span><span class="hl-brackets">)</span><span class="hl-default">:

	</span><span class="hl-identifier">fullname</span><span class="hl-default"> = </span><span class="hl-identifier">os</span><span class="hl-default">.</span><span class="hl-identifier">path</span><span class="hl-default">.</span><span class="hl-identifier">abspath</span><span class="hl-brackets">(</span><span class="hl-identifier">os</span><span class="hl-code">.</span><span class="hl-identifier">path</span><span class="hl-code">.</span><span class="hl-identifier">join</span><span class="hl-brackets">(</span><span class="hl-identifier">os</span><span class="hl-code">.</span><span class="hl-identifier">path</span><span class="hl-code">.</span><span class="hl-identifier">dirname</span><span class="hl-brackets">(</span><span class="hl-identifier">__file__</span><span class="hl-brackets">)</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">data</span><span class="hl-quotes">'</span><span class="hl-brackets">))
	</span><span class="hl-identifier">fullname</span><span class="hl-default"> = </span><span class="hl-identifier">os</span><span class="hl-default">.</span><span class="hl-identifier">path</span><span class="hl-default">.</span><span class="hl-identifier">join</span><span class="hl-brackets">(</span><span class="hl-identifier">fullname</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">images</span><span class="hl-quotes">'</span><span class="hl-brackets">)
	</span><span class="hl-identifier">fullname</span><span class="hl-default"> = </span><span class="hl-identifier">os</span><span class="hl-default">.</span><span class="hl-identifier">path</span><span class="hl-default">.</span><span class="hl-identifier">join</span><span class="hl-brackets">(</span><span class="hl-identifier">fullname</span><span class="hl-code">, </span><span class="hl-identifier">name</span><span class="hl-brackets">)
	</span><span class="hl-reserved">print </span><span class="hl-identifier">fullname
	</span><span class="hl-reserved">try</span><span class="hl-default">:
		</span><span class="hl-identifier">image</span><span class="hl-default"> = </span><span class="hl-identifier">pygame</span><span class="hl-default">.</span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">load</span><span class="hl-brackets">(</span><span class="hl-identifier">fullname</span><span class="hl-brackets">)
	</span><span class="hl-reserved">except </span><span class="hl-identifier">pygame</span><span class="hl-default">.</span><span class="hl-identifier">error</span><span class="hl-default">, </span><span class="hl-identifier">message</span><span class="hl-default">:
		</span><span class="hl-reserved">print </span><span class="hl-quotes">'</span><span class="hl-string">Cannot load image:</span><span class="hl-quotes">'</span><span class="hl-default">, </span><span class="hl-identifier">fullname
		</span><span class="hl-reserved">raise SystemExit</span><span class="hl-default">, </span><span class="hl-identifier">message
	image</span><span class="hl-default"> = </span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">convert</span><span class="hl-brackets">()
	</span><span class="hl-reserved">if </span><span class="hl-identifier">colorkey </span><span class="hl-reserved">is not None</span><span class="hl-default">:
		</span><span class="hl-reserved">if </span><span class="hl-identifier">colorkey </span><span class="hl-reserved">is</span><span class="hl-default"> -</span><span class="hl-number">1</span><span class="hl-default">:
			</span><span class="hl-identifier">colorkey</span><span class="hl-default"> = </span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">get_at</span><span class="hl-brackets">((</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-brackets">))
		</span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">set_colorkey</span><span class="hl-brackets">(</span><span class="hl-identifier">colorkey</span><span class="hl-code">, </span><span class="hl-identifier">RLEACCEL</span><span class="hl-brackets">)
	
	</span><span class="hl-reserved">return </span><span class="hl-identifier">image</span><span class="hl-default">, </span><span class="hl-identifier">image</span><span class="hl-default">.</span><span class="hl-identifier">get_rect</span><span class="hl-brackets">()</span></pre></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: potte</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-35425</link>
		<dc:creator>potte</dc:creator>
		<pubDate>Fri, 29 Jun 2007 10:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-35425</guid>
		<description>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</description>
		<content:encoded><![CDATA[<p>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</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: selsine</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-20911</link>
		<dc:creator>selsine</dc:creator>
		<pubDate>Sat, 05 May 2007 15:55:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-20911</guid>
		<description>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:

[code lang="python"]
print "START: import"
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'
print "END: import"
[/code]

[code lang="python"]
if __name__ == "__main__":
    print "Entering Main function"
    MainWindow = PyManMain()
    print "Starting Main Loop"
    MainWindow.MainLoop()
    print "Exiting"
[/code]

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.</description>
		<content:encoded><![CDATA[<p>Hmm, so you don&#8217;t get any error messages when you run it from the commandline?</p>
<p>Well then I would suggest adding some debug print messages to the code. For example:</p>
<div class="hl-surround" ><div class="hl-main"><pre><span class="hl-reserved">print </span><span class="hl-quotes">&quot;</span><span class="hl-string">START: import</span><span class="hl-quotes">&quot;
</span><span class="hl-reserved">import </span><span class="hl-identifier">os</span><span class="hl-default">, </span><span class="hl-identifier">sys
</span><span class="hl-reserved">import </span><span class="hl-identifier">pygame
</span><span class="hl-reserved">from </span><span class="hl-identifier">pygame</span><span class="hl-default">.</span><span class="hl-identifier">locals </span><span class="hl-reserved">import</span><span class="hl-default"> *

</span><span class="hl-reserved">if not </span><span class="hl-identifier">pygame</span><span class="hl-default">.</span><span class="hl-identifier">font</span><span class="hl-default">: </span><span class="hl-reserved">print </span><span class="hl-quotes">'</span><span class="hl-string">Warning, fonts disabled</span><span class="hl-quotes">'
</span><span class="hl-reserved">if not </span><span class="hl-identifier">pygame</span><span class="hl-default">.</span><span class="hl-identifier">mixer</span><span class="hl-default">: </span><span class="hl-reserved">print </span><span class="hl-quotes">'</span><span class="hl-string">Warning, sound disabled</span><span class="hl-quotes">'
</span><span class="hl-reserved">print </span><span class="hl-quotes">&quot;</span><span class="hl-string">END: import</span><span class="hl-quotes">&quot;</span></pre></div></div>
<div class="hl-surround" ><div class="hl-main"><pre><span class="hl-reserved">if </span><span class="hl-identifier">__name__</span><span class="hl-default"> == </span><span class="hl-quotes">&quot;</span><span class="hl-string">__main__</span><span class="hl-quotes">&quot;</span><span class="hl-default">:
    </span><span class="hl-reserved">print </span><span class="hl-quotes">&quot;</span><span class="hl-string">Entering Main function</span><span class="hl-quotes">&quot;
    </span><span class="hl-identifier">MainWindow</span><span class="hl-default"> = </span><span class="hl-identifier">PyManMain</span><span class="hl-brackets">()
    </span><span class="hl-reserved">print </span><span class="hl-quotes">&quot;</span><span class="hl-string">Starting Main Loop</span><span class="hl-quotes">&quot;
    </span><span class="hl-identifier">MainWindow</span><span class="hl-default">.</span><span class="hl-identifier">MainLoop</span><span class="hl-brackets">()
    </span><span class="hl-reserved">print </span><span class="hl-quotes">&quot;</span><span class="hl-string">Exiting</span><span class="hl-quotes">&quot;</span></pre></div></div>
<p>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&#8217;t working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JoeBob</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-20136</link>
		<dc:creator>JoeBob</dc:creator>
		<pubDate>Wed, 02 May 2007 20:28:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-20136</guid>
		<description>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!</description>
		<content:encoded><![CDATA[<p>I&#8217;m sorry, but all it does is instantly close. I&#8217;ve gotten one thing to work: The Sprite tutorial, with the boxes. For the most part, that&#8217;s it. Everything else, if it has no errors, will just pull up the pygame window, wait a millisecond, and then close! I don&#8217;t know if there&#8217;s anything else I should download or anything, but I would if it could fix the problem. If there is anything, I&#8217;d try it! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: selsine</title>
		<link>http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/#comment-19761</link>
		<dc:creator>selsine</dc:creator>
		<pubDate>Sun, 29 Apr 2007 20:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningpython.com/?p=19#comment-19761</guid>
		<description>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.</description>
		<content:encoded><![CDATA[<p>Hi JoeBob,</p>
<p>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.</p>
<p>Hopefully that information will let us know what the problem is.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
