Showing posts with label Particle. Show all posts
Showing posts with label Particle. Show all posts

Monday, June 27, 2011

Particle implementation.

Hi internet!

I've just successfully finished my oral exam (damn that sounds dirty).
So my time as an apprentice is officially over, which means I have more time now to focus on my 2D engine.

In this post I want to show you how I implemented the particle system in my engine using the decorator pattern.

First some UML:

As you might see here I decided to derive the particle emitter into a finite and an infinite subclass. The finite emitter stopps after it spawned n particle (determined by the setParticleAmount() method) whereas the infinite emitter runs as long as isStarted() return true.

The most difficult thing was to cover all the things a particle system must do (e.g. transparency, spreading, collision detection, etc.).






To provide all those contingencies I decided to use the decorator pattern (I just read the book Head First Design Patterns (a really good book), so all that stuff was still in my mind ;) ).

The particle system runs pretty well, although some of the subsystems (especially the transparency) don't work as expected yet.