0
\$\begingroup\$

I am trying to work out the protocols to set up a game between 2 players and the ideas behind getting the timing right between those two players in a running race game. Since this is obviously a timed race on a stop watch (about 4 minutes total), there are syncing issues.

What are the protocols?

In my game the server does not list all games available all across the world. All it does is facilitate a game between 2 players, such as those in a real world cafe, who can pass each other their unique id codes by word of mouth. The server is just there to administer the connection and dish out id codes.

  1. Should I connect to the WebRTC server straight away when the client loads a webpage? There are practice modes and games against the computer that do not require WebRTC connections.

  2. Should I let the user choose when to connect to the WebRTC server after the web page loads, so they can do practices or games against the AI?

  3. One person will start the game, setting all the options, eg uphill etc. How do I stop multiple connected and linked players altering those options? Should it be the first person to start a game out of all those connected and linked who bumps all the other players into the game with the options chosen on their machine?

  4. Should there be a waiting room area to stop the game timer counting while everyone's graphics load on their machine? (Different running tracks have different graphics that load at the race start.)

  5. Or should I let linked players just enter into a game at any time, even after it has started? There are some longer races that can last up to 10 minutes.

This latter option would allow a player in a game to pause their game when they meet someone in the cafe, and that new person could then join mid-race, taking on one of the other previously AI controlled runners.

  1. Most importantly of all there is obviously a lag between players. This is a timed race, ranging from 4 minutes to 10 minutes. How do I marry-up the times between players? Should I try to marry up as much as possible between the two clients, but consider the TRUE time of each player to be the time on their CLIENT machine?

By this I mean the following.

Assume 'Player A' finishes at 4 minutes dead on his machine and it appears on 'As' machine 'Player B' finished at 4 minutes and 1 second (due to lag issues).

However, on 'Player B's' machine it appears to 'Player B' he finished the race at 3mins 59 seconds.

Should I take the race times as 'Player A' = 4 mins and 'Player B' = 3mins 59 seconds? Ie the true finish time of a player is what occurs on the player's own machine, not the other person's?

Note: since these are friendly games between two people in a cafe, cheating is not an issue. They are playing in front of each other in real life.

Is there any documentation of best practices? How would you do it?

\$\endgroup\$
3
  • \$\begingroup\$ You have a lot of questions here, so they will not all have one answer. Moreover, you seem to already have the answers to many of them: "Should I connect to the WebRTC server straight away when the client loads a webpage?" well, if "There are practice modes and games against the computer that do not require WebRTC connections" then it sounds like you yourself are leaning toward "no". Have confidence in your own assessment. You know your own game's needs better than we do. \$\endgroup\$ Commented Sep 5, 2021 at 15:51
  • \$\begingroup\$ But the bad thing about asking the player to join the WebRTC server at a time after page-load is it is an added layer of requirement on the user. If it is auto-done at page load, then it is one less thing for the player to think about. Its just a case of look at their id, and tell it to their mate. \$\endgroup\$ Commented Sep 5, 2021 at 16:07
  • \$\begingroup\$ Then that sounds like a user experience call that, again, you are the person empowered to make. These are your players and this is your server bandwidth you're paying for (not to mention dev time). What trade-off is most palatable for your budget and player experience goals? This isn't a decision you can outsource, because the priorities and budget of some stranger on the Internet like me might be very different from what's practical or acceptable for you. \$\endgroup\$ Commented Sep 5, 2021 at 16:14

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.