renamed all .h to .hpp
[supertux.git] / src / object / particlesystem_interactive.hpp
1 //  $Id: ParticleSystem_Interactive.h 2462 2005-05-10 15:38:16Z wansti $
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 #ifndef SUPERTUX_PARTICLESYSTEM_INTERACTIVE_H
20 #define SUPERTUX_PARTICLESYSTEM_INTERACTIVE_H
21
22 #include <vector>
23
24 #include "video/surface.hpp"
25 #include "game_object.hpp"
26 #include "serializable.hpp"
27 #include "sector.hpp"
28 #include "math/vector.hpp"
29
30 namespace lisp {
31 class Lisp;
32 }
33
34 class DisplayManager;
35
36 /**
37  * This is an alternative class for particle systems. It is responsible for storing a
38  * set of particles with each having an x- and y-coordinate the number of the
39  * layer where it should be drawn and a texture.
40  * This version of the particle system class doesn't use virtual screen coordinates,
41  * but Interactive ones. Particle systems which need Interactive levels coordinates, such
42  * as rain, should be implemented here.
43  * Classes that implement a particle system should subclass from this class,
44  * initialize particles in the constructor and move them in the simulate
45  * function.
46  */
47 class ParticleSystem_Interactive : public GameObject
48 {
49 public:
50     ParticleSystem_Interactive();
51     virtual ~ParticleSystem_Interactive();
52     
53     virtual void draw(DrawingContext& context);
54
55 protected:
56     int layer;
57
58     class Particle
59     {
60     public:
61         virtual ~Particle()
62         { }
63
64         Vector pos;
65         Surface* texture;
66     };
67     
68     std::vector<Particle*> particles;
69     float virtual_width, virtual_height;
70     int collision(Particle* particle, Vector movement);
71 };
72
73 class RainParticleSystem : public ParticleSystem_Interactive, public Serializable
74 {
75 public:
76     RainParticleSystem();
77     virtual ~RainParticleSystem();
78
79     void parse(const lisp::Lisp& lisp);
80     void write(lisp::Writer& writer);
81
82     virtual void update(float elapsed_time);
83
84     std::string type() const
85     { return "RainParticleSystem"; }
86     
87 private:
88     class RainParticle : public Particle
89     {
90     public:
91         float speed;
92     };
93     
94     Surface* rainimages[2];
95 };
96
97 class CometParticleSystem : public ParticleSystem_Interactive, public Serializable
98 {
99 public:
100     CometParticleSystem();
101     virtual ~CometParticleSystem();
102
103     void parse(const lisp::Lisp& lisp);
104     void write(lisp::Writer& writer);
105
106     virtual void update(float elapsed_time);
107
108     std::string type() const
109     { return "CometParticleSystem"; }
110     
111 private:
112     class CometParticle : public Particle
113     {
114     public:
115         float speed;
116     };
117     
118     Surface* cometimages[2];
119 };
120
121 #endif
122