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->pos.x = graphicsRandom.rand(int(virtual_width));
+ particle->pos.y = graphicsRandom.rand(int(virtual_height));
+ int rainsize = graphicsRandom.rand(2);
particle->texture = rainimages[rainsize];
do {
- particle->speed = (rainsize+1)*45 + systemRandom.randf(3.6);
+ particle->speed = (rainsize+1)*45 + graphicsRandom.randf(3.6);
} while(particle->speed < 1);
particle->speed *= 10; // gravity
void
RainParticleSystem::parse(const Reader& reader)
{
- reader.get("z-pos", z_pos);
+ z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1);
}
RainParticleSystem::~RainParticleSystem()
//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
+ int splash_x, splash_y; // move outside if statement when
+ // uncommenting the else statement below.
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));
+ Sector::current()->add_object(std::make_shared<RainSplash>(Vector(splash_x, splash_y),vertical));
}
// Uncomment the following to display vertical splashes, too
/* else {
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_x = graphicsRandom.rand(int(virtual_width)) + int(abs_x);
int new_y = 0;
//FIXME: Don't move particles over solid tiles
particle->pos.x = new_x;