From 3b3aa0cc5979fd0c15ce75e4fd1406487727869b Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Mon, 3 Jul 2006 22:57:32 +0000 Subject: [PATCH] Experimenting with Bomb explosions and particles SVN-Revision: 3863 --- src/badguy/bomb.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index e765869d8..7d30a436d 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -20,6 +20,8 @@ #include #include "bomb.hpp" +#include "random_generator.hpp" +#include "object/sprite_particle.hpp" static const float TICKINGTIME = 1; static const float EXPLOSIONTIME = 1; @@ -113,6 +115,20 @@ Bomb::explode() sprite->set_action("explosion"); sound_manager->play("sounds/explosion.wav", get_pos()); timer.start(EXPLOSIONTIME); + + // 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 = systemRandom.randf(-M_PI_2, M_PI_2); + float velocity = systemRandom.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/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); + } + } void -- 2.11.0