2-player game, client and server at localhost

Michael Rybak accepted at ukr.net
Mon Aug 1 11:07:59 EDT 2005


Again, thank you very much for your help.

DLB>         The server should basically handle the multiple client
DLB> connection logic, and determination of interactions between movable
DLB> objects -- collision detection, for example (and I don't mean in the
DLB> terms of graphics rendering but in terms of object one at current
DLB> movement intersecting object two moving at some other vector).

My problem is: there are about 30 movable objects, so transferring
all their coordinates is much more traffic consuming (about 150 bytes
per transfer) rather than sending only user's motions (10 bytes per
transfer). But on the other hand, sending user's motions between two
non-server-neither-clients means that I needed stricted
synchronization, which means the turn-based approach, as you've said.


DLB>         I'm also NOT a game programmer, so I'm not sure how well most of
DLB> them separate screen updates from I/O, but I'd turn the above loop into
DLB> something like:


DLB> create screen thread
DLB> create I/O thread

DLB> {screen thread}
DLB> loop:
DLB>         compute/display screen using snapshot of "local status"

DLB> {I/O thread}
DLB> loop
DLB>         if keyboard has activity
DLB>                 read data
DLB>                 send data to server
DLB>         if server has activity
DLB>                 read data
DLB>                 update local status

DLB>         Note that the keyboard, in this simple example, never affects
DLB> the local (client) display -- only the status sent back by the server is
DLB> used. Okay, you may need to process things like "quit" locally <G>.

Well, this look really elegant, but will need me some time to rewrite
my networking that way. Thank's a lot, I'll let you know when it
works.

[..snip..]

]DLB>         The server looks like:

DLB> loop
DLB>         if new client connect
DLB>                 add client to list of clients
DLB>                 send client current status
DLB>         if data from client
DLB>                 update world state (collision detects, damage, etc.)
DLB>                 for c in client list
DLB>                         send current status
DLB>         if client disconnect
DLB>                 remove client from list

consider this part:
DLB>         if data from client
DLB>                 update world state (collision detects, damage, etc.)
DLB>                 for c in client list
DLB>                         send current status
the problem is - I should do this not "if data from client", but every
50 milliseconds or so, because objects are still moving when not
affected by users. To give you a better idea of what my game is:

Each player controls a snake, which is 2 to 12 balls connected to each
other with ropes; by mouse motions you move the snake's head, and the
rest of the body moves adhering normal physics. The objective/gameplay
is unimportant here, but if you're curios - all the balls of your
snake are bullets, and right-clicking releases current tail. So, you
have to spin around, and release the tail in appropriate moment so it
reaches your opponent, causing as much damage as much impulse it had.
There are health-pots and other stuff on game field of course.

So, you see - server will have to send current status as much time per
second, as much fps I want, and that's quite a lot of data.

I'd also like to mention (if I haven't already) that I have a 33.6
modem, while the friend I'm testing with has a 2 Mbit dedicated line,
if this is the right term.


I also was advised (by Peter Hansen) to try using Twisted, Pyro os
something like that. I've looked at Pyro, and tried using it, without
a lot of success compared to what I have now. I'm starting a new topic
here, describing my experiment.


DLB>         Recall my warning -- I'm not a game programmer; this is just how
DLB> /I'd/ consider implementing something like this.
You're being very helpful anyway :)


DLB> -- 
DLB>  > ============================================================== <
DLB>  >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
DLB>  >      wulfraed at dm.net     |       Bestiaria Support Staff       <
DLB>  > ============================================================== <
DLB>  >           Home Page: <http://www.dm.net/~wulfraed/>            <
DLB>  >        Overflow Page: <http://wlfraed.home.netcom.com/>        <



-- 
Best Regards,
 Michael Rybak                       mailto:accepted at ukr.net




More information about the Python-list mailing list