X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fparticlesystem.cpp;h=fa435be83dba6f3068d0fd1a9ff0c3d4c29cbbc6;hb=555d1b7bebb45326d82d934e07463209837309b0;hp=82446049bea1aff9c22e41b247b2deee630c1253;hpb=c7aee35e741fb4aeea3b6813d9fc6aea11e9b2e6;p=supertux.git diff --git a/src/object/particlesystem.cpp b/src/object/particlesystem.cpp index 82446049b..fa435be83 100644 --- a/src/object/particlesystem.cpp +++ b/src/object/particlesystem.cpp @@ -32,10 +32,11 @@ #include "object/camera.hpp" #include "random_generator.hpp" -ParticleSystem::ParticleSystem() +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; + virtual_width = SCREEN_WIDTH + max_particle_size * 2; + virtual_height = SCREEN_HEIGHT + max_particle_size *2; z_pos = LAYER_BACKGROUND1; } @@ -53,7 +54,7 @@ void ParticleSystem::draw(DrawingContext& context) float scrolly = context.get_translation().y; context.push_transform(); - context.set_translation(Vector(MAX_PARTICLE_SIZE,MAX_PARTICLE_SIZE)); + context.set_translation(Vector(max_particle_size,max_particle_size)); std::vector::iterator i; for(i = particles.begin(); i != particles.end(); ++i) { @@ -137,10 +138,10 @@ void SnowParticleSystem::update(float elapsed_time) particle->pos.y += particle->speed * elapsed_time; particle->pos.x += particle->wobble * elapsed_time /* * particle->speed * 0.125*/; - + anchor_delta = (particle->anchorx - particle->pos.x); particle->wobble += (4 * anchor_delta * 0.05) + systemRandom.randf(-0.5, 0.5); - particle->wobble *= 0.99; + particle->wobble *= 0.99f; particle->anchorx += particle->drift_speed * elapsed_time; } } @@ -162,10 +163,7 @@ 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); } } @@ -205,6 +203,7 @@ void GhostParticleSystem::update(float elapsed_time) } CloudParticleSystem::CloudParticleSystem() + : ParticleSystem(128) { cloudimage = new Surface("images/objects/particles/cloud.png");