This is a particle system implemented using coroutines. The demo comes with a commented implementation of the system plus two example particle effects. The particle system itself takes 55 tokens, the two example particles take 63 tokens each.
In this system a particle is defined as a function, and its states are stored in local variables inside the function. Creating a particles means creating a coroutine using the particle's function and saving the coroutine to a table. The coroutine is resumed during every _draw callback where it draws the particle on the screen and updates its state, and yields once it is done for the frame. The particle is considered "dead" and removed from the memory once the function in the coroutine finishes running.
This is the particle system I first developed for an unfinished game and subsequently used in my first finished PICO-8 game. I have not seen anything similar to it, and people on the PICO-8 Discord server seem interested, so I made a demo to showcase it.
[Please log in to post a comment]