src/object/fireworks.cpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #include "audio/sound_manager.hpp"
00018 #include "math/random_generator.hpp"
00019 #include "object/camera.hpp"
00020 #include "object/fireworks.hpp"
00021 #include "object/particles.hpp"
00022 #include "supertux/globals.hpp"
00023 #include "supertux/sector.hpp"
00024 #include "video/drawing_context.hpp"
00025 
00026 Fireworks::Fireworks() :
00027   timer()
00028 {
00029   timer.start(.2f);
00030   sound_manager->preload("sounds/fireworks.wav");
00031 }
00032 
00033 Fireworks::~Fireworks()
00034 {
00035 }
00036 
00037 void
00038 Fireworks::update(float )
00039 {
00040   if(timer.check()) {
00041     Sector* sector = Sector::current();
00042     Vector pos = sector->camera->get_translation();
00043     pos += Vector(graphicsRandom.randf(SCREEN_WIDTH),
00044                   graphicsRandom.randf(SCREEN_HEIGHT/2));
00045 
00046     float red = graphicsRandom.randf(1.0);
00047     float green = graphicsRandom.randf(1.0);
00048     //float red = 0.7;
00049     //float green = 0.9;
00050     (void) red;
00051     (void) green;
00052     sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
00053                                      Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f,
00054                                      LAYER_FOREGROUND1+1));
00055     sound_manager->play("sounds/fireworks.wav");
00056     timer.start(graphicsRandom.randf(1.0, 1.5));
00057   }
00058 }
00059 
00060 void
00061 Fireworks::draw(DrawingContext& )
00062 {
00063 }
00064 
00065 /* EOF */

Generated on Mon Jun 9 03:38:19 2014 for SuperTux by  doxygen 1.5.1