Firework Launcher (Example Of Lists)

Published 2023-06-12


Particle theory, the ability of creating particles in a programing language and then deleting them from a list, is a pretty new concept for me.

http://natureofcode.com/book/chapter-4-particle-systems/

I'm more apt to creating an array of a fixed size of elements I need and then using zero (0) for X or something to flag particles that do not appear.

However, PICO does support LISTS, which enables you to create all kinds of data constructs and store them literally like trays at a cafeteria.

Adding an item to the list is easy. Instead of keeping track of the last place where you inserted an item, just use the ADD() command with your parameters and sub-class variable definitions.

When you are done with it, instead of changing one of the numbers to zero, you can literally DELETE the whole sub-class set and it and your list is that much shorter and faster to run.

You can do this by using the DEL() command.

To keep track of them all, you use the function "IN ALL()" I.E.: FOR I IN ALL(BIT)

Try running the code above. Press (Z) to launch a particle into the air and watch as gravity takes hold of it.

Now look over the source code (it's only 32-lines long) and see how these three concepts of IN ALL(), ADD(), and DEL(), are made use of.

Thanks to Tyroney for showing me this concept earlier.