tzachshabtay / MonoAGS

AGS (Adventure Game Studio) reimagined in Mono
https://tzachshabtay.github.io/MonoAGS/
Artistic License 2.0
27 stars 8 forks source link

Suggestion: deltaTime in RepeatedlyExecute event #234

Closed ghost closed 6 years ago

ghost commented 6 years ago

Would that be possible to pass "float deltaTime" as an argument to the OnRepeatedlyExecute event? deltaTime would mean a virtual time passed since last tick.

Currently one would have to do something like -

// frame time in seconds
float deltaTime = (float)(1.0 / AGSGame.UPDATE_RATE);

in every class or repexec handler where they need to know it, but this is far from ideal, because one could miss possible global settings, and such approach is not forward compatible.

I think, by default deltaTime may be calculated by IGame implementation from UPDATE_RATE, but there could be more options added, such as adjusting it to real time (in case game updates are running slower than expected).

Additionally, user could subscribe same class to a medium, placed between IGame and game objects, and if the medium adjusts the virtual time, that would also work seamlessly if such "deltaTime" parameter existed.

Guess this is related to #192, idk if it conflicts with your ideas of frame-rate independence implementation. EDIT: I've just read the article you linked in #192, and apparently they speak of same "dt" variable there. So it may be you've already planned same thing? I just think that this event argument could be added even without frame-rate independence, for starters.

tzachshabtay commented 6 years ago

Right, this is a sub-set of what I wanted to do with #192 , but can be done before that.