Hi everyone!
I'm working on the movement server for my game, and ran into a big problem.
Here is the pseudo code:
pMoveSpeed = 5;
if (Movement_Keys.a == 1)
{
pSprite.x -= pMoveSpeed;
}
Holding down a moves a player towards the left. And this is for w,s,d too. This is inside the game loop.
When the player pushes down the a key this data gets sent:
(last number is the amount of frames passed in the update func)
--- POS a1,200
When the player releases the a key, this gets sent:
--- POS a0,250
As you can see, the player released the key 50 frames after. Which I then use this frame on the server, to multiply the pMoveSpeed variable to determine the players location.
This works well.. But there is only one problem.
My game is instance based like Diablo 2. So, players can join a game, go to their dungeon, etc.
When the player is holding down a, and let's say someone joins the game. The server actually has no idea where that player is at, because he hasn't released a yet. Is there a way around this?
Edit: The server knows where the origin of that player is at (Map starting position), but the time elapsed when the player is holding a, and the time it takes for the player to join will result in unsynchronized positions