Closed davidmball closed 4 years ago
Thanks. I will try it and maybe add it if it work well :)
Do you think I should add a parameter to choose the frame rate?
I'm not sure exactly how the frame rate should be configured for Phaser io as there are render, physics, etc frame rates. Perhaps as this is headless for a server it doesn't matter.
Perhaps as this is headless for a server it doesn't matter.
That's what I thought while making it. The client and the server are 100% separated. The frame rate of the server does not really have an impact of the clients frame rate, nor does it have an impact on how many time the servers sends an update to the client.
EDIT: Just noticed that you were talking about the frame rate. This part seems to be working for me and probably most people use 60 fps anyway. The matter physics engine used by phaser io seems to take the same step size regardless of fps anyway.
I noticed this when I was trying to synchronise matter physics across the client and server. The update steps on the server was slower than the client, and the matter physics engine takes fixed steps with each update loop. These update loops will be slower on the server.
I have added the option to adjust the fps.
I noticed that server and client clocks were quickly becoming desynced. I think the issue is that in the animation frame the delay is added on rather than measured against a fixed time schedule. I'd suggest changing it to something like this:
Additionally this assume 60Hz although this is a configurable parameter for Phaser io.