Michael Rybak <[EMAIL PROTECTED]> wrote:
> Hi, everyone.
> In topic "2-player game, client and server at localhost", I've asked
> about subj, and Peter Hansen suggested to switch to Twisted, Pyro or
> the like.
> 
> I've tried using Pyro.
> 
> I've written a very very simple test-game, in which you have 2 balls
> controlled by 2 players. Each player moves his mouse somewhere at
> his window, and his ball starts moving towards the pointer. No
> objectives, just to test how it works. The code is very small, so I
> can put it all here, skipping obvious stuff.
> 
> I've tried playing this test-game via local-host - all is ok.
> Then I've tested via Internet connection with my friend. I have a
> 33.6 Kbps modem, he has a 2 MBps dedicated line (if this is the term),
> and we ran a server at his pc and both connected to it. His ball ran as
> a child, smoothly and quickly, while I had about 5 fps :(, and for him
> it looked like my ball is simply very slow. I realise that client at
> my pc *has* to work slower than the client at server's pc, but hey,
> I've played Quake2 and WarCraft 2 via 33.6 modem, and those should have
> much more stuff to transfer per second :(
> 
> Please help me in any way you can think of. I'd welcome links to
> Python games written with Pyro, tips on what I am doing wrong, on not
> Pythonically enough - anything.


Do not use pyro, use simple UDP protocol. 
I've written networked tetris in python, communicating via
UDP protocol, and used it successfully on very congested lines.
If all you need is to transfer pointer coordinates, UDP is perfect since
you do not need feedback.

use something like this for server:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', port))
while 1:
    data, addr = s.recvfrom(1024)
    print `data`


and for client:

import socket

outsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
outsock.bind(('', 0))
outsock.sendto('message', ('server-hostname', server_port))



-- 
 -----------------------------------------------------------
| Radovan GarabĂ­k http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__    garabik @ kassiopeia.juls.savba.sk     |
 -----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to