[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Fwd: Soc Simple Networking
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Fwd: Soc Simple Networking
- From: "andrew baker" <failrate@xxxxxxxxx>
- Date: Mon, 1 May 2006 22:50:54 -0700
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Tue, 02 May 2006 01:51:01 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=Wco35USrRE1LTnpF+QC2yL9KOo12NgZXVrSkUJ4sdpGEVZJxdDYoJl3T02uyr2RYdYFX0w3L2oRZX+p4ZBWQwX0hbkcmO9nHseRGGvhhglp7t7FalkT2s5d607Nqj3NGNq5B8jU+4LWLKRhiVaDicZPKOKfuUNXOtNnGjIgWoI8=
- In-reply-to: <1146537902.6326.2.camel@localhost>
- References: <1146537902.6326.2.camel@localhost>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
As far as passing events and what-not, I can't imagine that bit will be too hard. I whipped up a recording and playback system in just a couple hours in the crudest manner I could (see below). Right away, you might point out that I could have serialized the events to save me a rat's nest of if...elif structures. In this example, pack vectorEvent and unpackVectorEvent both feed from and to a file, but that could just as easily be a UDP socket, which are cheap as chips and twice as easy in Python.
However, the real trick is when the UDP messages are received out of order, or with a large amount of lag or latency. Handling those contingencies is my number-one priority when looking at an event handler right now.
Whatever networking system is developed, only proper ordering and management of sockets is really important to me, as a user/developer, at the client side. I would, however, be very interested in SDL's server networking stuff given a nice Python wrapper.
Thank you,
Andrew Ulysses Baker
"failrate"
if world.PLAYBACK:
uve_set = unpackVectorEvent(ticks)
if uve_set != None:
for uve in uve_set:
if uve == 'QUIT':
running = 0
elif uve == 'KEYDOWN_LEFT':
world.ego.startLeft()
<-- snip -->
elif uve == 'KEYUP_ACTION_3':
world.ego.stopAction(3)
else:
for event in
pygame.event.get():
if event.type == QUIT:
if world.RECORD: vectorEvent(ticks, "QUIT")
running = 0
elif event.type == KEYDOWN:
if event.key == profile.keyMap[0]:
if world.RECORD: vectorEvent(ticks, "QUIT")
running = 0
<-- snip -->
elif event.key == profile.keyMap[11]:
edit.mode
= 1
edit.indicator.initialize_editing()
elif event.type == KEYUP:
if event.key ==
profile.keyMap[1]:
if world.RECORD: vectorEvent(ticks, "KEYUP_LEFT")
world.ego.stopLeft()
<-- snip -->
elif event.key == profile.keyMap[8]:
if world.RECORD: vectorEvent(ticks, "KEYUP_ACTION_3")
world.ego.stopAction
(3)