So for the past few weeks I have been spending all my time working on the multiplayer side of the game. I fixed a lot of bugs and I added a lot of new features.
So let me tell you what I added:-
1- Now you can disconnect from the lobby.
2- Now you can chat in the lobby. (Fixed all bugs)
3- Ready and Start Game button was added.
4- Now you can start the game from the lobby after everyone get ready.
5- The host can add towers and the client will add them too. (Like actual Multiplayer).
6- Enemies are in sync. So if the client start lagging the game will still be in sync.
Sorry for the aspect ratio.
In the older version of the game there was an issue where if the client starts lagging the game will be out of sync and enemies position in the server will be different from enemies position in the client. In other words what is on one client screen will be totally different on the other client screen.
So I fixed this issue by sending the enemy position ever 30 milliseconds. In other word I send the enemy position 33 frames per second. If you watch the video you will notice that the client is not lagging anymore, even though I’m only sending the enemy position 33 framers per seconds. I made both the server and client enemies move according to their path that is set in the map file. Just like in the older version of the game. However I added an if statement that say, if the client starts lagging and get out of sync, then use the positions of the server enemy. So that way I don’t use a lot of bandwidth and I make the gameplay smooth as butter.
Here was the issue:-