Skip to main content
gamedev.net
🔒 Locked

LATENCY PROBLEM

Started by carl404 Jan 20, 2005 at 10:23 AM 1 replies 500+ views
Original Post
carl404
carl404
hi! I wrote a little multiplayer game. It's a simple 2D game simmilar to dyna blaster. each player can run on the map and place bombs. The problem is that I use a very simple algorithm to for the communication. In each frame each player must send his key state to the server and then server sends keys of all players to each of them. Players can render new frame. It is very good to keep the game synchronized. But as you probably already see this method will fail if the latency will be greater than 30ms (I run this game with 30fps). I perform 30 send(...) commands each second. It is to much! Players must wait for the server to deliver the new keys and the real game frame rate drops to 10fps or something like this. I want to change my algorithm that it will only send changes of the keyboard states. I don't know how to keep it synchronized so each of the players will render exactly the same number of frames. carl
jake_Ghost
jake_Ghost
that last post had soem mistakes cause i had to go cause i was at skool, instead of doin it in a loop u hsould do it like this...

BOOL keyPress [256];BOOL keySave [256];// ur main loop// get ur keystatescase WM_KEYDOWN:												// Update Keyboard Buffers For Keys Pressed			if ((wParam >= 0) && (wParam <= 255))						// Is Key (wParam) In A Valid Range?			{				keyPress [wParam] = TRUE;					// Set The Selected Key (wParam) To True                                if (keySave[wParam] != keyPress[wParam])                                {                                    keySave[wParam] = TRUE;                                    // update teh server with ur current keystats or w/e u update                                   }				return 0;												// Return			}		break;															// Break		case WM_KEYUP:													// Update Keyboard Buffers For Keys Released			if ((wParam >= 0) && (wParam <= 255))						// Is Key (wParam) In A Valid Range?			{				keyPress [wParam] = FALSE;					// Set The Selected Key (wParam) To False                                if (keySave[wParam] != keyPress[wParam])                                {                                    keySave[wParam] = FALSE;                                    // update teh server with ur current keystats or w/e u update                                   }				return 0;												// Return			}		break;	

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.