-// $Id: particlesystem.cpp 2470 2005-05-11 14:49:28Z wansti $
-//
+// $Id$
+//
// SuperTux
-// Copyright (C) 2004 Matthias Braun <matze@braunis.de>
+// 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
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// 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.
+
#include <config.h>
#include <iostream>
#include "object/camera.hpp"
#include "object/rainsplash.hpp"
#include "badguy/bomb.hpp"
+#include "random_generator.hpp"
//TODO: Find a way to make rain collide with objects like bonus blocks
// Add an option to set rain strength
{
virtual_width = SCREEN_WIDTH;
virtual_height = SCREEN_HEIGHT;
- layer = LAYER_TILES;
+ z_pos = 0;
}
ParticleSystem_Interactive::~ParticleSystem_Interactive()
std::vector<Particle*>::iterator i;
for(i = particles.begin(); i != particles.end(); ++i) {
Particle* particle = *i;
- context.draw_surface(particle->texture, particle->pos, layer);
+ context.draw_surface(particle->texture, particle->pos, z_pos);
}
context.pop_transform();
RainParticleSystem::RainParticleSystem()
{
- rainimages[0] = new Surface("images/objects/particles/rain0.png", true);
- rainimages[1] = new Surface("images/objects/particles/rain1.png", true);
+ rainimages[0] = new Surface("images/objects/particles/rain0.png");
+ rainimages[1] = new Surface("images/objects/particles/rain1.png");
virtual_width = SCREEN_WIDTH * 2;
size_t raindropcount = size_t(virtual_width/6.0);
for(size_t i=0; i<raindropcount; ++i) {
RainParticle* particle = new RainParticle;
- particle->pos.x = rand() % int(virtual_width);
- particle->pos.y = rand() % int(virtual_height);
- int rainsize = rand() % 2;
+ 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 + (float(rand()%10)*.4);
+ particle->speed = (rainsize+1)*45 + systemRandom.randf(3.6);
} while(particle->speed < 1);
particle->speed *= 10; // gravity
void
RainParticleSystem::parse(const lisp::Lisp& reader)
{
- reader.get("layer", layer);
+ reader.get("z-pos", z_pos);
}
void
RainParticleSystem::write(lisp::Writer& writer)
{
writer.start_list("particles-rain");
- writer.write_int("layer", layer);
+ writer.write_int("z-pos", z_pos);
writer.end_list("particles-rain");
}
Sector::current()->add_object(new RainSplash(Vector(splash_x, splash_y),vertical));
} */
}
- int new_x = (rand() % int(virtual_width)) + int(abs_x);
+ 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;
CometParticleSystem::CometParticleSystem()
{
- cometimages[0] = new Surface("images/creatures/mr_bomb/exploding-left-0.png", true);
- cometimages[1] = new Surface("images/creatures/mr_bomb/exploding-left-0.png", true);
+ 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;
size_t cometcount = 2;
for(size_t i=0; i<cometcount; ++i) {
CometParticle* particle = new CometParticle;
- particle->pos.x = rand() % int(virtual_width);
- particle->pos.y = rand() % int(virtual_height);
- int cometsize = rand() % 2;
+ 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 + (float(rand()%10)*.4);
+ particle->speed = (cometsize+1)*30 + systemRandom.randf(3.6);
} while(particle->speed < 1);
particle->speed *= 10; // gravity
void
CometParticleSystem::parse(const lisp::Lisp& reader)
{
- reader.get("layer", layer);
+ reader.get("z-pos", z_pos);
}
void
CometParticleSystem::write(lisp::Writer& writer)
{
writer.start_list("particles-comets");
- writer.write_int("layer", layer);
+ writer.write_int("z-pos", z_pos);
writer.end_list("particles-comets");
}
if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)) {
Sector::current()->add_object(new Bomb(particle->pos, LEFT));
}
- int new_x = (rand() % int(virtual_width)) + int(abs_x);
+ 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;