The BIG COMMIT(tm)
[supertux.git] / src / object / fireworks.cpp
1 #include <config.h>
2
3 #include "fireworks.h"
4 #include "resources.h"
5 #include "sector.h"
6 #include "camera.h"
7 #include "app/globals.h"
8 #include "video/drawing_context.h"
9 #include "audio/sound_manager.h"
10
11 using namespace SuperTux;
12
13 Fireworks::Fireworks()
14 {
15   timer.start(.2);
16 }
17
18 Fireworks::~Fireworks()
19 {
20 }
21
22 void
23 Fireworks::action(float )
24 {
25     if(timer.check()) {
26         Sector* sector = Sector::current();
27         Vector pos = sector->camera->get_translation();
28         pos += Vector(screen->w * ((float) rand() / RAND_MAX),
29                       screen->h/2 * ((float) rand() / RAND_MAX));
30
31         int red = rand() % 255;
32         int green = rand() % red;
33         sector->add_particles(pos, 0, 360, Vector(140, 140),
34                 Vector(0, 0), 45, Color(red, green, 0), 3, 1300,
35                 LAYER_FOREGROUND1+1);
36         SoundManager::get()->play_sound(IDToSound(SND_FIREWORKS));
37         timer.start(((float) rand() / RAND_MAX) + .5);
38     }
39 }
40
41 void
42 Fireworks::draw(DrawingContext& )
43 {
44 }