On Fri, Feb 22, 2008 at 11:36 AM, Nathan <[EMAIL PROTECTED]> wrote:
>
> On Thu, Feb 21, 2008 at 2:06 PM, Drew Smathers <[EMAIL PROTECTED]> wrote:
> > > Twisted and "simple" have nothing to do with each other in my
> > > experience.
> >
> > I'm sorry to hear that :( Do you think low-level socket programming is
> simple?
> >
> > > I even bought the Twisted book, but I have a really hard
> > > time getting into it (not to mention that the developers seem to live
> > > on the opposite side of the world and have odd attitudes when you
> > > start asking them questions).
> >
> > Really? I've found the people on the Twisted mailing list to be very
> > helpful and take a lot of time to explain features of the library or
> > provide links to the appropriate documentation. The same can be said
> > of the IRC channel. Questions generally don't go ignored. So please
> > don't go hating on people who are working hard to answer questions day
> > in and day out (for a nominal fee of $0 per question), and continue to
> > write and maintain awesome open source software.
>
> Well, I suppose it's time for me to give Twisted a try again. I had
> my bad experiences with it back in 2005, so hopefully much has changed
> since then. I'll join the ML this time instead of poking around IRC.
> At least the twisted web site has graphics this time around, so maybe
> they have some decent docs too...
>
> So any advice on the competing event loops?
>
That's great to hear. :)
David's PausingRector seems interesting - and might be especially
relevant in turn-based games. There are also other easy ways to
integrate with the default reactor on your platform. One such way is
to use a Coiterator. For example:
from twisted.internet import reactor, task
from twisted.python import log
import sys
class Runtime:
...
def run(self):
while not win.has_exit:
...
yield 1
def shutdown(self, result):
print 'bye'
reactor.stop()
def bailout(self, reason):
reason.printTraceback()
reactor.stop()
log.startLogging(sys.stdout)
runspot = Runtime()
task.coiterate(runspot.run()).addCallback(runspot.shutdown).addErrback(runspot.bailout)
reactor.run()
Another technique is to use a LoopingCall. Some people want to keep
the reactor and the game in separate threads - so _threadedselect
reactor will help you do this. This is some (very ugly) code I hacked
out to test a threadedselect with pyglet:
http://hg.enterthefoo.com/Yue/file/fdab6dcbd1c4/docs/examples/game/game.py
(see LoopingRuntime class)
Twisted of course provides non-blocking I/O so you can sometimes get
slightly better performance if you don't use an additional thread.
These days I just use coiterators as described above.
For you semi-real-time protocol layer, I would strongly suggest
looking into AMP - it's a wire-level, bidirectional, extensible remote
messaging protocol:
http://twistedmatrix.com/trac/browser/trunk/twisted/protocols/amp.py
Hope this helps.
Cheers,
--
\\\\\/\"/\\\\\\\\\\\
\\\\/ // //\/\\\\\\\
\\\/ \\// /\ \/\\\\
\\/ /\/ / /\/ /\ \\\
\/ / /\/ /\ /\\\ \\
/ /\\\ /\\\ \\\\\/\
\/\\\\\/\\\\\/\\\\\\
d.p.s
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---