Written October 4th 2025
Task Queueing
I'm not sure who exactly I am writing this for, as I'm not sure this is interesting for someone less into programming, and for someone who is,
this probably isn't particularly novel or revolutionary.
I hope someone finds it useful or informative.
I frequently find myself, when programming animation systems for games, encountering an issue relating to sequencing different events.
I want to make an animation play, then open a dialogue menu, then when that menu is closed, move an object and play another animation.
In the past if I wanted to make something like this, I have to manually write a unique script for every event, ensuring everything was properly syncronised and timed correctly.
This is excruciatingly boring and time consuming, and I longed for a single system that could handle all sorts of actions. I eventually developed a system I cannot imagine myself not using, called "task queueing".
First, I define something called a task. A task is an operation that runs for an amount of time before terminating. This can be a fixed delay, an animation, or something dynamic, like waiting for user input.
The task parent object has two boolean variables, "started" and "finished", and two methods, "start" and "step".
"started" Determines whether the task has begun or not. If true, it is running. If false, it is currently sitting in a task queue waiting to begin.
"finished" Determines whether a task has ended. If true, the task has ended, and the queue knows to move on to the next task.
"start" Executes when a task has begun to be executed by the queue.
"step" Runs every game frame until the task finishes.
A task queue is a queue structure that moves through a series of tasks, running each task until it finishes before moving on to the next.
Here are a few example tasks I've made. Keep in mind that this system was originally made for Gamemaker.
TaskDelay(delay): Stops after a number of milliseconds.
TaskFunction(func): Runs a function every step until it returns "true".
TaskObject(obj): Creates an object, and stops when the object is destroyed.
TaskKeyPress(key): Stops when a key has been pressed.
TaskMove(obj,x,y,time): Moves an object to a position over a duration of time.
Some tasks can contain other tasks within them.
TaskCondition(task,condition): Runs the task only if a condition has been met. Otherwise, stops immedietly.
TaskQueue(tasks): A task queue, as a task. Runs through a list of tasks one by one until they've all stopped.
TaskListParallel(tasks): Runs through a list of tasks all at once, stopping when the every task has stopped. Combining this with TaskQueue can create complex sequences.
I've written this system twice, once in gamemaker and another time in java. I might upload them later, idk, they're pretty poorly written by my standards.