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 #include "object/cloud_particle_system.hpp"
21 #include "math/random_generator.hpp"
22 #include "supertux/globals.hpp"
23 #include "video/drawing_context.hpp"
25 CloudParticleSystem::CloudParticleSystem() :
29 cloudimage = Surface::create("images/objects/particles/cloud.png");
31 virtual_width = 2000.0;
33 // create some random clouds
34 for(size_t i=0; i<15; ++i) {
35 CloudParticle* particle = new CloudParticle;
36 particle->pos.x = systemRandom.rand(static_cast<int>(virtual_width));
37 particle->pos.y = systemRandom.rand(static_cast<int>(virtual_height));
38 particle->texture = cloudimage.get();
39 particle->speed = -systemRandom.randf(25.0, 54.0);
41 particles.push_back(particle);
46 CloudParticleSystem::parse(const Reader& reader)
48 reader.get("z-pos", z_pos);
51 CloudParticleSystem::~CloudParticleSystem()
55 void CloudParticleSystem::update(float elapsed_time)
57 std::vector<Particle*>::iterator i;
58 for(i = particles.begin(); i != particles.end(); ++i) {
59 CloudParticle* particle = (CloudParticle*) *i;
60 particle->pos.x += particle->speed * elapsed_time;