Delayed procedure calls (frame based)?
Posted: Tue May 22, 2012 12:41 pm
I am looking at this code that can be used to delay procedure calls, seems this could be (with a slight modification) very useful in a frame based games - for example after clearing the stage in some shooting game we might want to schedule the following tasks:
- generate a sequence of time delayed explosions
- generate new enemies
The RunTasks() would then each time (each frame) decrease the delay variable and execute the call when delay (counter) would reach zero.
However, it would be nice to be able to call the procedures with variable parameters, something as this code, so I wonder if it is possible to implement something similar to JavaScript setTimeout() method? That would be some kind of FIFO stack for the procedure calls including the parameters.
- generate a sequence of time delayed explosions
- generate new enemies
Code: Select all
For n = 1 To 20
RegisterTask(@create_explosion(), 10*n, #False)
Next
;new stage after 500 frames
RegisterTask(@create_new_enemies(), 500, #False) ;5 s after the last explosionHowever, it would be nice to be able to call the procedures with variable parameters, something as this code, so I wonder if it is possible to implement something similar to JavaScript setTimeout() method? That would be some kind of FIFO stack for the procedure calls including the parameters.