Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[supertux.git] / src / object / fireworks.cpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #include "audio/sound_manager.hpp"
18 #include "math/random_generator.hpp"
19 #include "object/camera.hpp"
20 #include "object/fireworks.hpp"
21 #include "object/particles.hpp"
22 #include "supertux/main.hpp"
23 #include "supertux/sector.hpp"
24 #include "video/drawing_context.hpp"
25
26 Fireworks::Fireworks()
27 {
28   timer.start(.2f);
29   sound_manager->preload("sounds/fireworks.wav");
30 }
31
32 Fireworks::~Fireworks()
33 {
34 }
35
36 void
37 Fireworks::update(float )
38 {
39   if(timer.check()) {
40     Sector* sector = Sector::current();
41     Vector pos = sector->camera->get_translation();
42     pos += Vector(systemRandom.randf(SCREEN_WIDTH),
43                   systemRandom.randf(SCREEN_HEIGHT/2));
44
45     float red = systemRandom.randf(1.0);
46     float green = systemRandom.randf(1.0);
47     //float red = 0.7;
48     //float green = 0.9;
49     (void) red;
50     (void) green;
51     sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
52                                      Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f,
53                                      LAYER_FOREGROUND1+1));
54     sound_manager->play("sounds/fireworks.wav");
55     timer.start(systemRandom.randf(1.0, 1.5));
56   }
57 }
58
59 void
60 Fireworks::draw(DrawingContext& )
61 {
62 }
63
64 /* EOF */