YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
26 stars 8 forks source link

implement time source function for the start of and end of a frame. #5095

Open attic-stuff opened 7 months ago

attic-stuff commented 7 months ago

Is your feature request related to a problem?

no dear reader, this is more a classic and purely vain feature request and it is specifically for GMRT rather than the current runtime!

it would be very radical to have time source functions that executed at the beginning of a frame and the end of a frame. they could look something like this:

/* in a script asset */
global.pausecheck = time_source_frame_end(function() {
    if (input_checking(pause_button) == true) {
        global.gamestate = "paused";
    }
});

the expectation is that they would happen at the beginning and end of a frame regardless of the frame time, and that if you have multiple frame end/begin sources they would not execute in any specific order other than the start or finish of a frame. these should be able to loop, pause, and continue like any other time source.

Describe the solution you'd like

alternatively, instead of implementing a new time source function it could be a new time source unit of measurement like this:

/* in a script asset */
global.pausecheck = time_source_create(time_source_global, -1, time_source_units_frame_end, function() {
    if (input_checking(pause_button) == true) {
        global.gamestate = "paused";
    }
});

i think that this kind of time source would be invaluably useful for a myriad of cool things such as dealing with room transitions, handling game states, and even benchmarking algorithms that need to be smoothed over multiple frames.

Describe alternatives you've considered

No response

Additional context

if i absolutely need to do something at the very end of a frame i will use the draw gui end event, however this feels very naughty, and originally i was going to make this request as an entirely new event for objects that included a frame begin and frame end event.

thank you yyg peoples

hagand3 commented 7 months ago

I second this!

Alphish commented 5 months ago

Very much approved. Right now in my Mainframe library (https://github.com/Alphish/gm-mainframe) I use Begin Step event to measure the start of the frame, and Draw GUI End event to measure the end of the frame, but it also means I shouldn't use the Begin Step/Draw GUI End events on other objects not to interfere with the frame measurements. The time sources or events for before and after core frame processing would be perfect for this purposes without interfering with Begin Step/Draw GUI End events.