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