paralin / goterram

Go game logic for Terram.
1 stars 0 forks source link

physics: Y axis is inverted, scaling is wrong #23

Open paralin opened 7 years ago

paralin commented 7 years ago

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.