- added geometry option which allows SuperTux to run at any resolution
[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 "gameobjs.h"
8 #include "app/globals.h"
9 #include "video/drawing_context.h"
10 #include "audio/sound_manager.h"
11
12 using namespace SuperTux;
13
14 Fireworks::Fireworks()
15 {
16   timer.start(.2);
17 }
18
19 Fireworks::~Fireworks()
20 {
21 }
22
23 void
24 Fireworks::action(float )
25 {
26     if(timer.check()) {
27         Sector* sector = Sector::current();
28         Vector pos = sector->camera->get_translation();
29         pos += Vector(SCREEN_WIDTH * ((float) rand() / RAND_MAX),
30                       SCREEN_HEIGHT/2 * ((float) rand() / RAND_MAX));
31
32         int red = rand() % 255;
33         int green = rand() % red;
34         sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
35                 Vector(0, 0), 45, Color(red, green, 0), 3, 1.3,
36                 LAYER_FOREGROUND1+1));
37         SoundManager::get()->play_sound(IDToSound(SND_FIREWORKS));
38         timer.start(((float) rand() / RAND_MAX) + .5);
39     }
40 }
41
42 void
43 Fireworks::draw(DrawingContext& )
44 {
45 }