Open minecrawler opened 3 years ago
just my 2 cents, but this feels like something that belongs outside of the ECS framework itself. I think the only thing the framework should provide is some method to easily access deltaTime from one tick to the next. How and when the ticks run seems like something up to the specific implementation that might use the framework.
Since
world.run()
is the core of the whole game loop, it should support features which are expected of any good game loop executing logic, and I think one of the missing pieces is the ability to run the logic at fixed intervals. Usually, that means at 60 steps per second.I think using
setInterval()
would be a good fit for this instead of coming up with custom timing logic - but we'll have to see how it works out, especially with browsers currently scaling down precision because of security concerns.I think, making
run()
use fixed steps should be configured via the configuration parameter - there could be a field which sets the frequency. At the same time, logic has to be in place which makes sure that every step waits for the previous step to finish first and then execute, so that things don't go to undefined land at every hickup. Plus this has to be logged, because it might mean that the logic is too slow and developers have to optimize the code to run at the target frequency, or decrease the frequency.