I have a number of events that happen in a game. I want to control the time and order at which these events occur.
For example:
Event 1: Show some text on screen for N frames & play a sound effect
Event 2: Clear the text on the screen
My solution (maybe there is a better one), is to have a list of functions that contain the events. The events perform their behavior then return the next events to occur in the game. I thought of using List.map or List.collect because I am essentially mapping a list of events to a new list of events while performing some behavior code.
In the example above, Event1 can be composed of two functions: One that shows text and one that plays a sound (hence the need for a list). The function that shows text would return a copy of itself for N-1 frames then it would return Event2 which clears the text. The play sound function would return the equivalent of a no-op.
If this is a good solution, I could probably do it in C++ or C#. My goal is to do an equivalent or better solution in F#.