Sure, here's my basic Pyglet/Twisted loop that we settled on. I cut
out most of the extra stuff to just show how I made Twisted and pyglet
work together (which is basically a direct copy of what Drew did). I
thought I already posted it to this thread, but I suppose once more
won't hurt. I'm making a 2D networked game. For fun.
class RMWindow(window.Window):
def __init__(self, x, y):
super(RMWindow, self).__init__(x, y)
def install_amp_client(self, amp_client):
self.amp_client = amp_client
self.amp_client.callRemote(Register).addCallback(create_player)
def run(self):
while not self.has_exit:
dt = client_game_clock.tick()
self.dispatch_events()
self.clear()
self.draw()
self.flip()
yield 1
def shutdown(self, result):
reactor.stop()
def bailout(self, reason):
reason.printTraceback()
reactor.stop()
if __name__ == '__main__':
rm_window = RMWindow(VIEWPORT_WIDTH, VIEWPORT_HEIGHT)
client_factory = ClientCreator(reactor,
RMClientProtocol).connectTCP('IPADDR',
PORT).addCallback(rm_window.install_amp_client)
task.coiterate(rm_window.run()).addCallback(rm_window.shutdown).addErrback(rm_window.bailout)
reactor.run()
On Tue, Mar 4, 2008 at 12:50 PM, Snor <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm also wanting to implement twisted while using pyglet.app... after
> reading the whole thread I'm still a little confused as to what final
> solution you eventually used. If I might be so cheeky as to ask you to
> provide me with the simplest example of this setup?
>
> Any help would be much appreciated!
>
> By the way I am curious as to what you plan on making :)
>
> Leo
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---