[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Network game programming with python
On Tuesday, Apr 15, 2003, at 15:27 America/New_York, RPGnMets@aol.com
wrote:
"In regard to your mainloop, what's wrong with registering those events
with the reactor? That's the Twisted way of doing things. Here's an
oversimplified example:
FRAMEDELAY = 1.0 / 30.0
def oneFrame():
handle_input()
update_game_entities()
draw_frame()
if not over:
# call oneFrame after a short delay
reactor.callLater(FRAMEDELAY, oneFrame)
if __name__ == '__main__':
from twisted.internet import reactor
gameSetup()
# call oneFrame at the next reactor iteration
reactor.callLater(0.0, oneFrame)
reactor.run()
gameShutdown()
"
I was thinking about doing something like this. That way, I can keep
the familair game loop while still benefitting from twisted for the
network stuff. However, where would the gamestate be kept?
Obviously, whatever twisted calls back into will need access to the
state somehow, and the mainloop needs state too.
That's what classes are for... or generators I guess, but you really
want to use classes.
-bob