[Tutor] Re: Help with a game
Andrei
project5 at redrival.net
Thu Nov 13 15:12:45 EST 2003
j j wrote on Thu, 13 Nov 2003 11:09:43 -0800 (PST):
> Whenever i run the game it says:
> script 'A:\game folder\game.py' returned exit code 0
<snip>
> Maybe some help? Thank you guys...here is the code.
There is no actual action in the code you sent. You define classes and
functions, but you don't do anything with them. So the script runs, reads
those definitions, thinks "yeah, they're nice" and then ends.
<snip>
> class ship(pygame.sprite.Sprite):
<snip>
> def _change(self):
<snip>
> allsprites.update()
> screen.blit(backround, (0, 0))
> allsprites.draw(screen)
> pygame.display.flip()
> if __name__ == '__main__':
> main()
Pay attention to your indentation! 'if __name__=="__main__"' is Python
idiom which goes at the bottom of the file with 0 indentation - in your
code, it's part of a method of the ship class because of its indentation
level. You also call in there the function main(), which is defined in the
code somewhere inside the _change() method of the ship class. Again, wrong
indentation.
You really should browse through a Python tutorial before attempting a
program of that size. And get a decent Python editor to help you with
indentation (SciTE, Spe, PythonWin).
--
Yours,
Andrei
=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
More information about the Tutor
mailing list