2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef HEADER_SUPERTUX_OBJECT_PARTICLESYSTEM_HPP
18 #define HEADER_SUPERTUX_OBJECT_PARTICLESYSTEM_HPP
22 #include "math/vector.hpp"
23 #include "supertux/game_object.hpp"
24 #include "util/reader.hpp"
25 #include "video/surface_ptr.hpp"
30 * This is the base class for particle systems. It is responsible for storing a
31 * set of particles with each having an x- and y-coordinate the number of the
32 * layer where it should be drawn and a texture.
33 * The coordinate system used here is a virtual one. It would be a bad idea to
34 * populate whole levels with particles. So we're using a virtual rectangle
35 * here that is tiled onto the level when drawing. This rect.has the size
36 * (virtual_width, virtual_height). We're using modulo on the particle
37 * coordinates, so when a particle leaves left, it'll reenter at the right
40 * Classes that implement a particle system should subclass from this class,
41 * initialize particles in the constructor and move them in the simulate
44 class ParticleSystem : public GameObject
47 ParticleSystem(float max_particle_size = 60);
48 virtual ~ParticleSystem();
50 virtual void draw(DrawingContext& context);
66 // angle at which to draw particle
71 Particle(const Particle&);
72 Particle& operator=(const Particle&);
75 float max_particle_size;
77 std::vector<Particle*> particles;