I can enlighten you (haha! Get it?....... *cough*) about the mechanics behind that 1 loop frame offset problem.
As already said the script are run before the screen is rendered. Additionally, all values are updated before the rendering, but after the scripts are run. Which means functions that run before the update are working with one frame old values.
Because in the sequence of events in the main loop, the repeatedly_execute_always and repeatedly_execute functions are run before the values are updated just in case the values were changed when those function are run.
There's a way to correct this. By making an update before the functions are run and another after for a double check.
I don't know if it will affect the frame rate, because it means going through huge arrays twice with the current engine architecture.
I have to test that, because I ran into the same problem, but resolved it by using a 0.5 frame offset hack; which only works with prerendered sprites though.
EDIT: Holy my holy! It works, but it runs twice its framerate. Which actually makes kind of sense. Needs more testing....
As already said the script are run before the screen is rendered. Additionally, all values are updated before the rendering, but after the scripts are run. Which means functions that run before the update are working with one frame old values.
Because in the sequence of events in the main loop, the repeatedly_execute_always and repeatedly_execute functions are run before the values are updated just in case the values were changed when those function are run.
There's a way to correct this. By making an update before the functions are run and another after for a double check.
I don't know if it will affect the frame rate, because it means going through huge arrays twice with the current engine architecture.
I have to test that, because I ran into the same problem, but resolved it by using a 0.5 frame offset hack; which only works with prerendered sprites though.
EDIT: Holy my holy! It works, but it runs twice its framerate. Which actually makes kind of sense. Needs more testing....