I am sorry for that period of absence. I hope that I can manage to write more frequently in the comming next months but I still have to pass my A-levels. There are also some other projects I still have to finish and my new car wants to get ready for the comming summer ;-) I worked the last weeks some time on this piece of Actionscript3. This is not only just another particle-example like all the others. What I wanted to create was an extensible particle system which could create nearly every effect like ParticleIllusion does it.
My source of inspiration was “Designing an Extensible Particle System using C++ and Templates” which is an article about extensible particle systems in C++. Since Flash is still not able to handle templates I had to think about other possibilities. An easy way to simulate templates is using interfaces and dataholder classes. But this is also a loss of performance. Not the best solution. A new language that handles templates is haXe. All what I can say is that haXe got a lot of very nice things like the templates, enums, etc. but I wanted to create this particle system for AS3 projects. This is one of the reasons why I used AS3 instead of haXe. Another reason is that I really like the Flex2 environment with all the nice code hints and so on.
The particle system is build up on the Policy Pattern. You can read about that in the article I talked about. The policy pattern allows you to combine effects in lots of ways. Most attributes of a particle have their own policy. One for the color, one for the position, for the velocity etc. Theese policies tell the particle how to behave. An easy example is the LifeAction which tells the particle to decrease the life value with a given speed.
The basis of my particle system is of course the smallest unit: a particle. Particles stay inside a ParticleGroup which handles memory management and emits particles at a given position. ParticleGroups can be attached to a ParticleTimeline or a ParticleSystem. A timeline is something that allows you to create a special effect. You are able to create a simple explosion on frame one for example and then show the blast wave after some frames. The nice thing is that you only have to emit this effect once and do not care about any memory management or objects.
Then there are the ParticleSystems which render all particles. A ParticleSystem can use textures or simple pixels. It can be additive (BlendMode.ADD) or whatever you like. Some systems I already created are additive and simple pixel systems. The same for textured systems.
The last thing is about policies. You can create combined policies. For example the ForceFieldAction uses a forcefield to set the velocity. You could combine this policy with the GravityAction which adds gravity to your particle. There are a lof of possibilities. The next thing which has to be done are more policies to allow a huge set of effects and also more ParticleSystems. The timelines also needs the ability to emit particles for a given interval. Physics would also be nice. But the goal is an editor that allows you to create nice effects for easy use.
- Fireworks (Timeline, Textured System)
- “PerlinForce” (Additive Pixel System, ForceField based on PerlinNoise)