X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Ffireworks.cpp;h=d218c061b442835370481b039e200158b1c7adfa;hb=77d00a6f464cc87c6b50cf1f3b38064a7ae9aead;hp=12b79b302b48b508c51db766bd478f0648f316a9;hpb=0540d5db4c57c585615a78ccf33603ff3628db95;p=supertux.git diff --git a/src/object/fireworks.cpp b/src/object/fireworks.cpp index 12b79b302..d218c061b 100644 --- a/src/object/fireworks.cpp +++ b/src/object/fireworks.cpp @@ -1,7 +1,7 @@ // $Id$ -// +// // SuperTux -// Copyright (C) 2005 Matthias Braun +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -12,25 +12,27 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + #include #include "fireworks.hpp" #include "resources.hpp" #include "sector.hpp" #include "camera.hpp" -#include "gameobjs.hpp" +#include "particles.hpp" #include "main.hpp" #include "video/drawing_context.hpp" #include "audio/sound_manager.hpp" +#include "random_generator.hpp" Fireworks::Fireworks() { timer.start(.2); + sound_manager->preload("sounds/fireworks.wav"); } Fireworks::~Fireworks() @@ -43,16 +45,20 @@ Fireworks::update(float ) if(timer.check()) { Sector* sector = Sector::current(); Vector pos = sector->camera->get_translation(); - pos += Vector(SCREEN_WIDTH * ((float) rand() / RAND_MAX), - SCREEN_HEIGHT/2 * ((float) rand() / RAND_MAX)); + pos += Vector(systemRandom.randf(SCREEN_WIDTH), + systemRandom.randf(SCREEN_HEIGHT/2)); - int red = rand() % 255; - int green = rand() % red; + float red = systemRandom.randf(1.0); + float green = systemRandom.randf(1.0); + //float red = 0.7; + //float green = 0.9; + (void) red; + (void) green; sector->add_object(new Particles(pos, 0, 360, Vector(140, 140), Vector(0, 0), 45, Color(red, green, 0), 3, 1.3, LAYER_FOREGROUND1+1)); - sound_manager->play("sounds/fireworks.ogg"); - timer.start(((float) rand() / RAND_MAX) + .5); + sound_manager->play("sounds/fireworks.wav"); + timer.start(systemRandom.randf(1.0, 1.5)); } }