Asked by Iknos.
SVN-Revision: 2078
int red = rand() % 255; // calculate firework color
int green = rand() % red;
currentsector->add_particles(epicenter, 0, 360, Vector(1.4,1.4),
- Vector(0,0), 45, Color(red,green,0), 3, 1300);
+ Vector(0,0), 45, Color(red,green,0), 3, 1300,
+ LAYER_FOREGROUND1+1);
SoundManager::get()->play_sound(IDToSound(SND_FIREWORKS));
random_timer.start(rand() % 400 + 600); // next firework
img_smoke_cloud->draw(context, position, LAYER_OBJECTS+1);
}
-Particles::Particles(const Vector& epicenter, int min_angle, int max_angle, const Vector& initial_velocity, const Vector& acceleration, int number, Color color_, int size_, int life_time)
- : color(color_), size(size_), accel(acceleration)
+Particles::Particles(const Vector& epicenter, int min_angle, int max_angle, const Vector& initial_velocity, const Vector& acceleration, int number, Color color_, int size_, int life_time, int drawing_layer_)
+ : color(color_), size(size_), accel(acceleration), drawing_layer(drawing_layer_)
{
if(life_time == 0)
{
// draw particles
for(std::vector<Particle*>::iterator i = particles.begin(); i < particles.end(); i++)
{
- context.draw_filled_rect((*i)->pos, Vector(size,size), color, LAYER_OBJECTS+10);
+ context.draw_filled_rect((*i)->pos, Vector(size,size), color, drawing_layer);
}
}
public:
Particles(const Vector& epicenter, int min_angle, int max_angle,
const Vector& initial_velocity, const Vector& acceleration,
- int number, Color color, int size, int life_time);
+ int number, Color color, int size, int life_time, int drawing_layer);
~Particles();
virtual void action(float elapsed_time);
virtual void draw(DrawingContext& context);
private:
- Color color;
- float size;
Vector accel;
Timer timer;
bool live_forever;
+ Color color;
+ float size;
+ int drawing_layer;
+
struct Particle {
Vector pos, vel;
// float angle;
Sector::current()->add_particles(
Vector(base.x + (dir == RIGHT ? base.width : 0), base.y+base.height),
dir == RIGHT ? 270+20 : 90-40, dir == RIGHT ? 270+40 : 90-20,
- Vector(2.8,-2.6), Vector(0,0.030), 3, Color(100,100,100), 3, 800);
+ Vector(2.8,-2.6), Vector(0,0.030), 3, Color(100,100,100), 3, 800,
+ LAYER_OBJECTS+1);
ax *= 2.5;
}
}
bool
-Sector::add_particles(const Vector& epicenter, int min_angle, int max_angle, const Vector& initial_velocity, const Vector& acceleration, int number, Color color, int size, int life_time)
+Sector::add_particles(const Vector& epicenter, int min_angle, int max_angle, const Vector& initial_velocity, const Vector& acceleration, int number, Color color, int size, int life_time, int drawing_layer)
{
- add_object(new Particles(epicenter, min_angle, max_angle, initial_velocity, acceleration, number, color, size, life_time));
+ add_object(new Particles(epicenter, min_angle, max_angle, initial_velocity, acceleration, number, color, size, life_time, drawing_layer));
return true;
}
void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind);
bool add_bullet(const Vector& pos, float xm, Direction dir);
bool add_smoke_cloud(const Vector& pos);
- bool add_particles(const Vector& epicenter, int min_angle, int max_angle, const Vector& initial_velocity, const Vector& acceleration, int number, Color color, int size, int life_time);
+ bool add_particles(const Vector& epicenter, int min_angle, int max_angle, const Vector& initial_velocity, const Vector& acceleration, int number, Color color, int size, int life_time, int drawing_layer);
void add_floating_text(const Vector& pos, const std::string& text);
/** Try to grab the coin at the given coordinates */