Split particlesystem_interactive.?pp into separate files
[supertux.git] / src / object / particlesystem_interactive.cpp
index e9a28be..b317071 100644 (file)
 #include "object/particlesystem_interactive.hpp"
 
 #include "math/aatriangle.hpp"
-#include "math/random_generator.hpp"
-#include "object/camera.hpp"
-#include "object/rainsplash.hpp"
 #include "object/tilemap.hpp"
 #include "supertux/collision.hpp"
-#include "supertux/globals.hpp"
 #include "supertux/tile.hpp"
-#include "util/reader.hpp"
 
 //TODO: Find a way to make rain collide with objects like bonus blocks
 //      Add an option to set rain strength
@@ -138,142 +133,4 @@ ParticleSystem_Interactive::collision(Particle* object, Vector movement)
   return 0;
 }
 
-RainParticleSystem::RainParticleSystem()
-{
-  rainimages[0] = new Surface("images/objects/particles/rain0.png");
-  rainimages[1] = new Surface("images/objects/particles/rain1.png");
-
-  virtual_width = SCREEN_WIDTH * 2;
-
-  // create some random raindrops
-  size_t raindropcount = size_t(virtual_width/6.0);
-  for(size_t i=0; i<raindropcount; ++i) {
-    RainParticle* particle = new RainParticle;
-    particle->pos.x = systemRandom.rand(int(virtual_width));
-    particle->pos.y = systemRandom.rand(int(virtual_height));
-    int rainsize = systemRandom.rand(2);
-    particle->texture = rainimages[rainsize];
-    do {
-      particle->speed = (rainsize+1)*45 + systemRandom.randf(3.6);
-    } while(particle->speed < 1);
-    particle->speed *= 10; // gravity
-
-    particles.push_back(particle);
-  }
-}
-
-void
-RainParticleSystem::parse(const Reader& reader)
-{
-  reader.get("z-pos", z_pos);
-}
-
-RainParticleSystem::~RainParticleSystem()
-{
-  for(int i=0;i<2;++i)
-    delete rainimages[i];
-}
-
-void RainParticleSystem::update(float elapsed_time)
-{
-  std::vector<Particle*>::iterator i;
-  for(
-    i = particles.begin(); i != particles.end(); ++i) {
-    RainParticle* particle = (RainParticle*) *i;
-    float movement = particle->speed * elapsed_time;
-    float abs_x = Sector::current()->camera->get_translation().x;
-    float abs_y = Sector::current()->camera->get_translation().y;
-    particle->pos.y += movement;
-    particle->pos.x -= movement;
-    int col = collision(particle, Vector(-movement, movement));
-    if ((particle->pos.y > SCREEN_HEIGHT + abs_y) || (col >= 0)) {
-      //Create rainsplash
-      if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)){
-        bool vertical = (col == 2);
-        int splash_x, splash_y;
-        if (!vertical) { //check if collision happened from above
-          splash_x = int(particle->pos.x);
-          splash_y = int(particle->pos.y) - (int(particle->pos.y) % 32) + 32;
-          Sector::current()->add_object(new RainSplash(Vector(splash_x, splash_y),vertical));
-        }
-        // Uncomment the following to display vertical splashes, too
-        /* else {
-           splash_x = int(particle->pos.x) - (int(particle->pos.x) % 32) + 32;
-           splash_y = int(particle->pos.y);
-           Sector::current()->add_object(new RainSplash(Vector(splash_x, splash_y),vertical));
-           } */
-      }
-      int new_x = systemRandom.rand(int(virtual_width)) + int(abs_x);
-      int new_y = 0;
-      //FIXME: Don't move particles over solid tiles
-      particle->pos.x = new_x;
-      particle->pos.y = new_y;
-    }
-  }
-}
-
-CometParticleSystem::CometParticleSystem()
-{
-  cometimages[0] = new Surface("images/creatures/mr_bomb/exploding-left-0.png");
-  cometimages[1] = new Surface("images/creatures/mr_bomb/exploding-left-0.png");
-
-  virtual_width = SCREEN_WIDTH * 2;
-
-  // create some random comets
-  size_t cometcount = 2;
-  for(size_t i=0; i<cometcount; ++i) {
-    CometParticle* particle = new CometParticle;
-    particle->pos.x = systemRandom.rand(int(virtual_width));
-    particle->pos.y = systemRandom.rand(int(virtual_height));
-    int cometsize = systemRandom.rand(2);
-    particle->texture = cometimages[cometsize];
-    do {
-      particle->speed = (cometsize+1)*30 + systemRandom.randf(3.6);
-    } while(particle->speed < 1);
-    particle->speed *= 10; // gravity
-
-    particles.push_back(particle);
-  }
-}
-
-void
-CometParticleSystem::parse(const Reader& reader)
-{
-  reader.get("z-pos", z_pos);
-}
-
-CometParticleSystem::~CometParticleSystem()
-{
-  for(int i=0;i<2;++i)
-    delete cometimages[i];
-}
-
-void CometParticleSystem::update(float elapsed_time)
-{
-  (void) elapsed_time;
-#if 0
-  std::vector<Particle*>::iterator i;
-  for(
-    i = particles.begin(); i != particles.end(); ++i) {
-    CometParticle* particle = (CometParticle*) *i;
-    float movement = particle->speed * elapsed_time;
-    float abs_x = Sector::current()->camera->get_translation().x;
-    float abs_y = Sector::current()->camera->get_translation().y;
-    particle->pos.y += movement;
-    particle->pos.x -= movement;
-    int col = collision(particle, Vector(-movement, movement));
-    if ((particle->pos.y > SCREEN_HEIGHT + abs_y) || (col >= 0)) {
-      if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)) {
-        Sector::current()->add_object(new Bomb(particle->pos, LEFT));
-      }
-      int new_x = systemRandom.rand(int(virtual_width)) + int(abs_x);
-      int new_y = 0;
-      //FIXME: Don't move particles over solid tiles
-      particle->pos.x = new_x;
-      particle->pos.y = new_y;
-    }
-  }
-#endif
-}
-
 /* EOF */