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. ############################server.py################# # [..imports..] class game__(game_, Pyro.core.ObjBase): def __init__(self): #storage for balls' coordinates game_.__init__(self) Pyro.core.ObjBase.__init__(self) [..server initialization..] daemon.requestLoop() END#########################server.py################# ############################client.py################# [..imports..] [..preparations to create proxy..] proxy=Pyro.core.getAttrProxyForURI(URI) [..imports..] def process_user_input(game, id):#id is client's id - 0 or 1 nx, ny = pygame.mouse.get_pos() x, y = game.ball[id].get_pos() dx, dy = nx - x, ny - y leng = sqrt(dx*dx + dy*dy) k = 20 / leng dx *= k dy *= k game.move(id, dx, dy) #remote call: move ball id = proxy.get_n_clients() #which ball to control if id < 2: proxy.new_client() pygame.init() scr = pygame.display.set_mode((640, 480)) g = game(proxy.get_status(), scr) #get_status provides 2 pairs of balls's current coordinates #g, "game" instance, is a local storage, able to render itself while 1: g.set_status(proxy.get_status()) g.render() process_user_input(proxy, id) time.sleep(0.03) [..quit = (ESCAPE is pressed)..] if quit: break END#########################client.py################# -- Best Regards, Michael Rybak mailto:[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list