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.
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.
Made a few changes in the code. Now when the firework hits its zenith, it releases an additional 16 other fireworks around it.
A single flag is used to tell that THESE new fireworks are all duds, and do not further explode into an additional 16, or as you could see, the program would hang rather quickly with each new firework igniting over and over again.
What are the results of one firework spawning 16 more ? Run and see ! :)
[Please log in to post a comment]