Rate my client/server structure

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
lazershark3k
Prole
Posts: 24
Joined: Tue Apr 10, 2018 3:20 pm

Rate my client/server structure

Post by lazershark3k »

Greetings denizens,
I'm making my first game in LÖVE for a school project. It's a 2d shooter, a remake of Stick Soldiers 2. I want to have online multiplayer, so it has client and server components. Both use the same 'Game' object. Game has a 'getState' method which grabs the status of each in-game object (xy coords, which weapons each player has, how much ammo/capacity each weapon has, etc.). Game also has an 'unpackState' method that, for each part of the state passed in, it updates or creates the corresponding object in the game.
Right now I'm running getState on every update on the server side, and sending it to the client, who runs 'unpackState' on their end. This is waaaaay too slow, but I'm not sure what the best way to make it good??? Help???
*pew pew*
SPlice
Prole
Posts: 48
Joined: Thu Jul 28, 2011 8:53 am

Re: Rate my client/server structure

Post by SPlice »

Don't update every frame. Send only things that change when they change(such as key presses and stat/inventory changes).
This will cut back on a lot of net traffic.
Have some kind of sync packet that can correct any deviation every half second or something for movement and a lot slower for stuff that does not change often. For movement make sure your lerping if there is deviation so stuff does not pop around.
User avatar
lazershark3k
Prole
Posts: 24
Joined: Tue Apr 10, 2018 3:20 pm

Re: Rate my client/server structure

Post by lazershark3k »

Thanks! That helps a lot! I'll have to google lerping
*pew pew*
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 46 guests