My netcode is working, but I have a question

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

My netcode is working, but I have a question

Post by cohadar »

Ok so I am making a mini multiplayer game
https://github.com/cohadar/tanks-of-harmony-and-love

Using lua-enet for networking.
Never made multiplayer game before, but I think I did netcode right, just not sure.

It works like this:
Love FPS is 60, I sample and send user commands to server at 30 FPS, server works at 60 FPS but updates clients at 10 FPS.
Clients and servers are in lockstep, they all have tick counter updated every 60 FPS.
When state on client and server gets different a resync is forced on client ( I display sync text on screen for debugging )

So far it is working fine, I just thought to ask nevertheless.
Am I doing something wrong? Could I be doing something better?
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: My netcode is working, but I have a question

Post by I~=Spam »

Fps isn't a good way to count because if fps is ever lower than 60 there will be a lot of mismatches. Unfortunately, I don't know how it should be done either... :crazy: What I would do it have a separate thread on the client that will try to ask server for an update and send updates every so many seconds using socket.sleep. This sub thread would communicate with the main thread via messages. The server would be written in pure lua + luasocket (so no love callbacks) and would be willing to get a message from its clients at any time.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests