More -Weffc++ cleanup
[supertux.git] / src / object / particlesystem.cpp
index 4db97d3..bb79f54 100644 (file)
@@ -1,12 +1,10 @@
-//  $Id$
-//
 //  SuperTux
 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
 //
 //  This program is distributed in the hope that it will be useful,
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  GNU General Public License for more details.
 //
 //  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.
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-#include <config.h>
+#include "object/particlesystem.hpp"
 
-#include <iostream>
 #include <cmath>
 
-#include "particlesystem.hpp"
+#include "math/random_generator.hpp"
+#include "supertux/main.hpp"
 #include "video/drawing_context.hpp"
-#include "lisp/parser.hpp"
-#include "lisp/lisp.hpp"
-#include "lisp/writer.hpp"
-#include "resources.hpp"
-#include "main.hpp"
-#include "object/camera.hpp"
-#include "random_generator.hpp"
-
-ParticleSystem::ParticleSystem(float max_particle_size)
-       : max_particle_size(max_particle_size)
+
+ParticleSystem::ParticleSystem(float max_particle_size) :
+  max_particle_size(max_particle_size)
 {
   virtual_width = SCREEN_WIDTH + max_particle_size * 2;
   virtual_height = SCREEN_HEIGHT + max_particle_size *2;
@@ -69,7 +59,6 @@ void ParticleSystem::draw(DrawingContext& context)
     pos.y = fmodf(particle->pos.y - scrolly, virtual_height);
     if(pos.y < 0) pos.y += virtual_height;
 
-
     //if(pos.x > virtual_width) pos.x -= virtual_width;
     //if(pos.y > virtual_height) pos.y -= virtual_height;
 
@@ -109,19 +98,11 @@ SnowParticleSystem::SnowParticleSystem()
 }
 
 void
-SnowParticleSystem::parse(const lisp::Lisp& reader)
+SnowParticleSystem::parse(const Reader& reader)
 {
   reader.get("z-pos", z_pos);
 }
 
-void
-SnowParticleSystem::write(lisp::Writer& writer)
-{
-  writer.start_list("particles-snow");
-  writer.write_int("z-pos", z_pos);
-  writer.end_list("particles-snow");
-}
-
 SnowParticleSystem::~SnowParticleSystem()
 {
   for(int i=0;i<3;++i)
@@ -163,28 +144,17 @@ GhostParticleSystem::GhostParticleSystem()
     particle->pos.y = systemRandom.randf(SCREEN_HEIGHT);
     int size = systemRandom.rand(2);
     particle->texture = ghosts[size];
-    do {
-      particle->speed = size*.2 + systemRandom.randf(3.6);
-    } while(particle->speed < 1);
-    particle->speed *= 50;
+    particle->speed = systemRandom.randf(std::max(50, (size * 10)), 180 + (size * 10));
     particles.push_back(particle);
   }
 }
 
 void
-GhostParticleSystem::parse(const lisp::Lisp& reader)
+GhostParticleSystem::parse(const Reader& reader)
 {
   reader.get("z-pos", z_pos);
 }
 
-void
-GhostParticleSystem::write(lisp::Writer& writer)
-{
-  writer.start_list("particles-ghosts");
-  writer.write_int("z-pos", z_pos);
-  writer.end_list("particles-ghosts");
-}
-
 GhostParticleSystem::~GhostParticleSystem()
 {
   for(int i=0;i<2;++i)
@@ -205,8 +175,8 @@ void GhostParticleSystem::update(float elapsed_time)
   }
 }
 
-CloudParticleSystem::CloudParticleSystem()
-       : ParticleSystem(128)
+CloudParticleSystem::CloudParticleSystem() :
+  ParticleSystem(128)
 {
   cloudimage = new Surface("images/objects/particles/cloud.png");
 
@@ -225,19 +195,11 @@ CloudParticleSystem::CloudParticleSystem()
 }
 
 void
-CloudParticleSystem::parse(const lisp::Lisp& reader)
+CloudParticleSystem::parse(const Reader& reader)
 {
   reader.get("z-pos", z_pos);
 }
 
-void
-CloudParticleSystem::write(lisp::Writer& writer)
-{
-  writer.start_list("particles-clouds");
-  writer.write_int("z-pos", z_pos);
-  writer.end_list("particles-clouds");
-}
-
 CloudParticleSystem::~CloudParticleSystem()
 {
   delete cloudimage;
@@ -251,3 +213,5 @@ void CloudParticleSystem::update(float elapsed_time)
     particle->pos.x += particle->speed * elapsed_time;
   }
 }
+
+/* EOF */