X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fparticlesystem.h;h=d11c5c13daaf309f2b3dda963862847d2365924e;hb=ee6972038331a3c26a2a6a0bdb2baca25475b1d2;hp=8efdf954084a5aff5d1872560d46e7acf618724d;hpb=c8ad8bb328dd90c0ab00e4c375b9a4b8f8df6e73;p=supertux.git diff --git a/src/particlesystem.h b/src/particlesystem.h index 8efdf9540..d11c5c13d 100644 --- a/src/particlesystem.h +++ b/src/particlesystem.h @@ -16,11 +16,23 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + #ifndef SUPERTUX_PARTICLESYSTEM_H #define SUPERTUX_PARTICLESYSTEM_H #include -#include "texture.h" + +#include "video/surface.h" +#include "special/game_object.h" +#include "serializable.h" + +using namespace SuperTux; + +namespace SuperTux { +class LispReader; +} + +class DisplayManager; /** * This is the base class for particle systems. It is responsible for storing a @@ -37,39 +49,44 @@ * initialize particles in the constructor and move them in the simulate * function. */ -class ParticleSystem +class ParticleSystem : public GameObject { public: ParticleSystem(); virtual ~ParticleSystem(); - void draw(float scrollx, float scrolly, int layer); - - virtual void simulate(float elapsed_time) = 0; + virtual void draw(DrawingContext& context); protected: + int layer; + class Particle { public: virtual ~Particle() { } - float x, y; - int layer; - texture_type* texture; + Vector pos; + Surface* texture; }; std::vector particles; float virtual_width, virtual_height; }; -class SnowParticleSystem : public ParticleSystem +class SnowParticleSystem : public ParticleSystem, public Serializable { public: SnowParticleSystem(); virtual ~SnowParticleSystem(); - virtual void simulate(float elapsed_time); + void parse(LispReader& reader); + void write(LispWriter& writer); + + virtual void action(float elapsed_time); + + std::string type() const + { return "SnowParticleSystem"; } private: class SnowParticle : public Particle @@ -78,16 +95,22 @@ private: float speed; }; - texture_type snowimages[3]; + Surface* snowimages[3]; }; -class CloudParticleSystem : public ParticleSystem +class CloudParticleSystem : public ParticleSystem, public Serializable { public: CloudParticleSystem(); virtual ~CloudParticleSystem(); - virtual void simulate(float elapsed_time); + void parse(LispReader& reader); + void write(LispWriter& writer); + + virtual void action(float elapsed_time); + + std::string type() const + { return "SnowParticleSystem"; } private: class CloudParticle : public Particle @@ -96,7 +119,7 @@ private: float speed; }; - texture_type cloudimage; + Surface* cloudimage; }; #endif