Skip to content

Commit

Permalink
Brought back particles for bomb explosions
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH0013 committed Nov 28, 2014
1 parent bae187e commit e513739
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
17 changes: 4 additions & 13 deletions src/object/explosion.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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<Particles>(
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 ();
Expand Down
2 changes: 1 addition & 1 deletion src/object/particles.cpp
Expand Up @@ -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);
}
Expand Down

0 comments on commit e513739

Please sign in to comment.