Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple world updates & rendering #268

Closed
nbraud opened this issue May 12, 2019 · 3 comments
Closed

Decouple world updates & rendering #268

nbraud opened this issue May 12, 2019 · 3 comments

Comments

@nbraud
Copy link
Contributor

nbraud commented May 12, 2019

This is an observation I made while working on #244.
AFAIK, we are currently (#244 or not) doing synchronous updates & rendering, with variable time steps, i.e. rendering is tied to game world updates, and both happen at non-deterministic times (tied to physical time & how fast things execute).

This means game-world updates are non-deterministic, which will likely be a major issue once we want to implement networking support: many/most approaches to networked games are much simpler (or possible at all) with deterministic state updates.

The standard solution is to decouple game-world updates from rendering, run updates on fixed time steps, and interleave rendering in-between world updates; this way, state updates are deterministic and do not lag behind (assuming the platform can keep up with state updates at all), and running on an underspec'd platform only results in fewer frames being rendered each second.

If we want to be fancy about it, we can even interpolate the position of objects at render-time (i.e. use obj.position + time_delta * obj.velocity as the effective position) for smoother motion.
That would involve introducing an (optional) API for position interpolation, since motion (and physics in general) isn't a core part of PPB (we don't even provide the concept), and users are free to implement their own.

@pathunstrom
Copy link
Collaborator

run updates on fixed time steps, and interleave rendering in-between world updates

We already do this. And after #221 we actually do this better. PPB has done fixed step simulation since the first version. Look at Updater for how it's currently implemented.

@nbraud
Copy link
Contributor Author

nbraud commented May 12, 2019

@pathunstrom Thanks, I had read through Updater and somehow misparsed the thing. >_>'

@nbraud nbraud closed this as completed May 12, 2019
@pathunstrom
Copy link
Collaborator

Was just checking. Yes, fixed step simulation is way better, and we should not stop doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants