From: LMH Date: Fri, 28 Nov 2014 20:47:55 +0000 (-1000) Subject: Brought back particles for bomb explosions X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e51373986670ef60e6628f477fc6e322780989de;p=supertux.git Brought back particles for bomb explosions --- diff --git a/src/object/explosion.cpp b/src/object/explosion.cpp index 828f02bb1..793518e63 100644 --- a/src/object/explosion.cpp +++ b/src/object/explosion.cpp @@ -20,6 +20,7 @@ #include "badguy/badguy.hpp" #include "badguy/walking_badguy.hpp" #include "math/random_generator.hpp" +#include "object/particles.hpp" #include "object/player.hpp" #include "object/sprite_particle.hpp" #include "sprite/sprite.hpp" @@ -70,20 +71,10 @@ Explosion::explode() sprite->set_angle(graphicsRandom.randf(0, 360)); // a random rotation on the sprite to make explosions appear more random SoundManager::current()->play(hurt ? "sounds/explosion.wav" : "sounds/firecracker.ogg", get_pos()); -#if 0 // spawn some particles - // TODO: provide convenience function in MovingSprite or MovingObject? - for (int i = 0; i < 100; i++) { - Vector ppos = bbox.get_middle(); - float angle = graphicsRandom.randf(-M_PI_2, M_PI_2); - float velocity = graphicsRandom.randf(450, 900); - float vx = sin(angle)*velocity; - float vy = -cos(angle)*velocity; - Vector pspeed = Vector(vx, vy); - Vector paccel = Vector(0, 1000); - Sector::current()->add_object(new SpriteParticle("images/objects/particles/explosion.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); - } -#endif + int pnumber = push ? 8 : 100; + Sector::current()->add_object(std::make_shared( + bbox.get_middle(), -360, 360, 450, 900, Vector(0, 1000), pnumber, Color(.4f, .4f, .4f), 3, .8f, LAYER_OBJECTS-1)); if (push) { Vector center = get_bbox ().get_middle (); diff --git a/src/object/particles.cpp b/src/object/particles.cpp index 6ee3ab191..1babe233c 100644 --- a/src/object/particles.cpp +++ b/src/object/particles.cpp @@ -91,7 +91,7 @@ Particles::Particles(const Vector& epicenter, int min_angle, int max_angle, float velocity = graphicsRandom.rand(min_initial_velocity, max_initial_velocity); float angle = graphicsRandom.rand(min_angle, max_angle) * (M_PI / 180); // convert to radians particle->vel.x = (cos(angle)) * velocity; - particle->vel.y = (sin(angle)) * velocity; + particle->vel.y = (-sin(angle)) * velocity; particles.push_back(particle); }