| 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 "object/fireworks.hpp" |
| 18 | |
| 19 | #include "audio/sound_manager.hpp" |
| 20 | #include "math/random.hpp" |
| 21 | #include "object/camera.hpp" |
| 22 | #include "object/particles.hpp" |
| 23 | #include "supertux/sector.hpp" |
| 24 | #include "video/drawing_context.hpp" |
| 25 | #include "video/video_system.hpp" |
| 26 | #include "video/viewport.hpp" |
| 27 | |
| 28 | Fireworks::Fireworks() : |
| 29 | timer() |
| 30 | { |
| 31 | timer.start(.2f); |
| 32 | SoundManager::current()->preload("sounds/fireworks.wav" ); |
| 33 | } |
| 34 | |
| 35 | void |
| 36 | Fireworks::update(float ) |
| 37 | { |
| 38 | if (timer.check()) { |
| 39 | Vector pos = Sector::get().get_camera().get_translation(); |
| 40 | pos += Vector(graphicsRandom.randf(static_cast<float>(SCREEN_WIDTH)), |
| 41 | graphicsRandom.randf(static_cast<float>(SCREEN_HEIGHT) / 2.0f)); |
| 42 | |
| 43 | float red = graphicsRandom.randf(1.0); |
| 44 | float green = graphicsRandom.randf(1.0); |
| 45 | Sector::get().add<Particles>( |
| 46 | pos, 0, 360, 140, 140, |
| 47 | Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f, |
| 48 | LAYER_FOREGROUND1+1); |
| 49 | SoundManager::current()->play("sounds/fireworks.wav" ); |
| 50 | timer.start(graphicsRandom.randf(1.0, 1.5)); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | void |
| 55 | Fireworks::draw(DrawingContext& ) |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | /* EOF */ |
| 60 | |