TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What is the best way to handle latency in a simple multiplayer game?

6 pointsby datafixabout 5 years ago
I&#x27;m making a multiplayer game. I&#x27;m just about done. I&#x27;ve got the mechanics worked out, I just need to handle latency in some way.<p>The game: tron lightcycles, but to turn, the user must solve a math problem.<p>What I&#x27;ve tried:<p><pre><code> 1. Update game state for every player every time either player changes direction. Why didn&#x27;t it work? Not the best way to handle it (also got that math wrong somewhere, and the undraw function would leave gaps in player trails) 2. Update game state for every player every 100ms. Why didn&#x27;t it work? Player 1 and player 2 are running different instances of the class that is supposed to update game state, and I can&#x27;t share the instance between the two </code></pre> Stack: Python&#x2F;Django, PostgreSQL, javscript&#x2F;jquery<p>I need help. Can anyone help?

2 comments

chomaabout 5 years ago
Here [1], Ricky &quot;Infil&quot; Pusch explains the two more used methods to workaround lag in fighting games. I&#x27;m not sure if this will be useful in your case, but it&#x27;s a great read anyway. I&#x27;m not a gamer but really enjoyed reading it.<p>[1]: <a href="http:&#x2F;&#x2F;ki.infil.net&#x2F;w02-netcode.html" rel="nofollow">http:&#x2F;&#x2F;ki.infil.net&#x2F;w02-netcode.html</a>
uvwabout 5 years ago
I would first find out source of your latency problem. Unless you can diagnose the problem first, you can&#x27;t fix it.