TheGameCreators / GameGuruRepo

The GameGuru Repository For Community Collaboration
http://www.game-guru.com
138 stars 56 forks source link

Optimzation Suggestion: New (optional) Script Parameter #5467

Closed TenebreGaming closed 2 months ago

TenebreGaming commented 2 months ago

Being able to reduce the rate that behavior scripts get called is great, but it causes issues with anything that renders to the screen (such as sprites or text) that are not persistent and result in "flickering". Might I suggest a better way of doing it?

Since some scripts need to run every frame and others do not, I would suggest adding an optional script parameter that specifies how often the script needs to be called (in milliseconds, since framerate varies). A script that needs to be called every frame would pass a value of 0. This could be done easily by adding a new (optional) entry at the head of the script, and could be implemented using the --DESCRIPTION or something new that is specifialy parsed such as "--FRAMETIMING 100", which would tell the engine to call the script every 100ms. Any script without this entry would be called every frame as usual.

Optionally, a new Lua command could be created that can vary the call speed of the script. For example, a LuaFrameTiming(100) call would tell the engine that the script should be called again in 100ms (it would remain at this timing until changed). This would eliminate the need for a script that is in a delay cycle from even being called (saving a lot of state switching internally). This would allow scripts to have variable timing as well as drastically reduce overhead. It would also move the timing to the script so it can be written specifically for variable timing or not depending on its specific needs.

It would also be nice if text and sprites could persist across skipped frames, but I understand that's a lot more work, but it could be done fairly easily.

Just a thought.

Necrym59 commented 2 months ago

Already has been planned