I made a small game were 2 players share a screen, they both edit the screen, but the screens are looking different at different times, how can i make both screens change at the exact time and stay accurate?
Printable View
I made a small game were 2 players share a screen, they both edit the screen, but the screens are looking different at different times, how can i make both screens change at the exact time and stay accurate?
Well? Is there anyway to make sure lag doesnt make the two screens differ?
You should sync the user inputs. For example: Users A and B, if they both make a move at the same time, you decide which move first. ie. if A decides to move first, then you make screen change according to A's move, then update all player screens before you allow B to move, and also check if B is a valid move because A might made some move that prevent B's movemeng.
Here, anyone can have a look, im kinda proud of this project, i made an older version that was 10x the ammount of code. See if you can solve my lag problem that causes the games to varry.
The only way to "solve" lag is to have a lagless connection - and that's not possible.
I dont mean to get rid of it, bah!, i want to do what every other game does, if theres lag, it makes everyone wait, or it speeds them up.
About the best you can do is constantly measure lag to each of your users (or have each user measure lag to the server) by pinging, but that uses a lot of bandwidth. There's no way to make lag an "event", or to trigger something if the connection lags.
damn, i guess il try sharing each players x and y coord's, and see how well that goes, i have a feeling the lines will skip.
I don't know what games you think have "solved" the lag problem, but my wife is a dedicated gamer, and complains about lag all the time, on some pretty sophisticated gaming systems. Not even IRC networks, some of which are over 10 years old, can do anything about lag except to reroute servers - and you don't want to do that unless you have someone doing just that all the time.