[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] the game.Mainloop() myth



hi eric

as far as i understand there is no such function in pygame. have you checked the docs?
http://www.pygame.org/docs/ref/event.html

In pygame you create your own loop, check the basic examples included with pygame like the chimp example
http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html

this is the main loop in that example

while 1:
    clock.tick(60)

my guess is that you have seen that in someone's code. you can code something like this and it should work.


class GameLoop :
	def MainLoop(self) :
		while 1:
    			clock.tick(60)

if __name__ == "__main__":
	gameloop = GameLoop()
	gameloop.Mainloop()

of course you would need to import and init pygame at the top of the script...


enrike

Eric Hunter(e)k dio:
okay so I'm trying to use the .Mainloop() and am getting an error.

[error]
GameLoop instance has no attribute 'MainLoop'

[/error]

and the code is

[code]
if __name__ == "__main__":
     gameloop = GameLoop()
     gameloop.Mainloop()
[/code]

is the Mainloop() just a myth or does it really work? do I need to import a certain function or something?

thanks in advance,

-Eric