2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
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.
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.
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/>.
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/globals.hpp"
23 #include "supertux/sector.hpp"
24 #include "video/drawing_context.hpp"
26 Fireworks::Fireworks() :
30 sound_manager->preload("sounds/fireworks.wav");
33 Fireworks::~Fireworks()
38 Fireworks::update(float )
41 Sector* sector = Sector::current();
42 Vector pos = sector->camera->get_translation();
43 pos += Vector(graphicsRandom.randf(SCREEN_WIDTH),
44 graphicsRandom.randf(SCREEN_HEIGHT/2));
46 float red = graphicsRandom.randf(1.0);
47 float green = graphicsRandom.randf(1.0);
52 sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
53 Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f,
54 LAYER_FOREGROUND1+1));
55 sound_manager->play("sounds/fireworks.wav");
56 timer.start(graphicsRandom.randf(1.0, 1.5));
61 Fireworks::draw(DrawingContext& )