Today I drastically refactored the particle engine, and now each emitter features a GenericMap and 3 lamdas (setup, spawn and particle_update).
By dividing the code in the three lambdas and passing data around with the GenericMap it is possible to build whatever kind of stuff inside the particle engine.
The system is not incredibly immediate if you don't know how it works, mainly because it is built in a very unconventional way, but now it is very well organized and give complete freedom to the game programmer.
For example, I created fireworks with the following emitters:
EMITTER 1:
Lambda creation: Setup yellow spheres, and attach to them EMITTER 2
Lambda spawn: Create the spheres and reset them to the original position/color
Lamda particle update: Move them and scale them up. When they are near their deaths make them invisible and tell EMITTER 2 to activate itself to simulate the explosion of the secondary firework.
EMITTER 2:
Lambda creation: Setup red cubes
Lambda spawn: Create the cubes and reset them to the position of the sphere
Lambda particle update: Move them to simulate the explosion

Nessun commento:
Posta un commento