with the help of the love2d wiki I started creating some more or less basic games but since this is getting boring over time ... I took another step that lead me towards creating a multiplayer game. I use the socket module and ofc my app communicates over UDP. Some forum posts gave me hints on how to plan the communication and I got the basic stuff working. But before I write too much, let's get to the facts+problem:
I'm using love2d version 11.1 on a Windows OS.
The goal is to create a(nother) 2D top-down shooter for local multiplayer (LAN only) (singleplayer is also possible, but not the main goal).
(so yes, my personal goal is to learn stuff about networking and shaders [which I might have some questions about, too ... maybe in another post ])
With "basic stuff working" I mean my app can send game entity information and apply them (server is always right). I have a simple lobby that lets players join and the host can select the map to play on and start the game ...
Now to my current obstacle: while the game runs smoothly at first (I'm testing it on one PC starting the game twice) it becomes more and more laggy after a few seconds (20 or so?). Note that I am not even sending a huge mass of information over the network. It is just 2 players and their movement (actually location, velocity vector and rotation). Hostile mobs etc are deactivated for now!
Before you ask for a .love file (which does not exist yet), let me show you my concrete questions:
Code: Select all
In every update tick the server and client do
Code: Select all
However, this all happens in one call of the tick function and here I am not quite sure if this buffer is actually helpful at all.
Do I have to find another structure for my "buffer"? (I'm gonna append a shortened version of my network lua file)
As you can see in the attached file, a client can send a "ping" to the server (client keypress) which responds asap -> the clients knows the time delay.
After some seconds of "gameplay" this delay becomes >2 seconds and even more when "playing" longer...
So the actual thing I do not understand is ... why is that? I do not see the reason behind that. Is my "buffer" concept wrong? Is there a problem with the transmission I do not notice? I mean ... being on ONE PC should not lead to these delays and my PC is clearly not old so this should not be the bottleneck here.
Thanks for reading so far, I appreciate any ideas/hints etc. If the network code is not enough to understand my problem, let me know and I will build my .love file for you to check. Cheers!