We have a ball that floats upwards slowly now, yay!
There are two things that need to be done to get physics to actually work properly.
[ ] Convert physics units into screen pixels in Pixi, make a generic dimension converter class.
[ ] Invert the Y axis. In the physics engine, Y=10 is above Y=0, makes sense. In Pixi, everything is from the top left down. So, y=10 is below Y=0.
[ ] Figure out what to do when the game update tick is suspended in the background.
About the update tick - the Update() functions are not called, or are called at a really slow rate, when the tab is in the background. We need to completely suspend the game when it's in the background, and unsuspend it when tabbing back in. This will mean requesting a full re-sync from the server in networked mode and in client mode... Probably pausing the game while tabbed out.
This could be solved with a web worker doing the game logic. The web worker could be crunching all the physics in the background while tabbed out, as the browser doesn't throttle web workers when the tab isn't in the foreground.
For now, the solution is:
Make a generic way of suspending the game logic
Make a generic way of resuming the game logic, and depending on the op mode, resyncing or not.
Don't suspend the game logic if we're using a web worker.
This will be transparent when the web workers are implemented down the line.
As far as I know, the networking should still work while suspended. Probably, we will want to tell the server we are paused, and then send only heartbeats or something, and display a "paused" screen.
We have a ball that floats upwards slowly now, yay!
There are two things that need to be done to get physics to actually work properly.
About the update tick - the Update() functions are not called, or are called at a really slow rate, when the tab is in the background. We need to completely suspend the game when it's in the background, and unsuspend it when tabbing back in. This will mean requesting a full re-sync from the server in networked mode and in client mode... Probably pausing the game while tabbed out.
This could be solved with a web worker doing the game logic. The web worker could be crunching all the physics in the background while tabbed out, as the browser doesn't throttle web workers when the tab isn't in the foreground.
For now, the solution is:
This will be transparent when the web workers are implemented down the line.
As far as I know, the networking should still work while suspended. Probably, we will want to tell the server we are paused, and then send only heartbeats or something, and display a "paused" screen.