X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fobject%2Ffireworks.cpp;h=8ecbb0a1e8ca5c5d0851cf89619a048436fc744b;hb=db14b806439363d7f4809d0d5e4187e356295841;hp=7047bf94beee2df57d9925d1c8987ca561dc0b59;hpb=86181b0a14d89cf45daf97199c3556c4dd1ee7b7;p=supertux.git diff --git a/src/object/fireworks.cpp b/src/object/fireworks.cpp index 7047bf94b..8ecbb0a1e 100644 --- a/src/object/fireworks.cpp +++ b/src/object/fireworks.cpp @@ -1,36 +1,33 @@ -// $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 -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // 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. -#include +// along with this program. If not, see . -#include "fireworks.hpp" -#include "resources.hpp" -#include "sector.hpp" -#include "camera.hpp" -#include "gameobjs.hpp" -#include "main.hpp" -#include "video/drawing_context.hpp" #include "audio/sound_manager.hpp" +#include "math/random_generator.hpp" +#include "object/camera.hpp" +#include "object/fireworks.hpp" +#include "object/particles.hpp" +#include "supertux/globals.hpp" +#include "supertux/sector.hpp" +#include "video/drawing_context.hpp" -Fireworks::Fireworks() +Fireworks::Fireworks() : + timer() { - timer.start(.2); + timer.start(.2f); + SoundManager::current()->preload("sounds/fireworks.wav"); } Fireworks::~Fireworks() @@ -40,23 +37,29 @@ Fireworks::~Fireworks() void 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)); + if(timer.check()) { + Sector* sector = Sector::current(); + Vector pos = sector->camera->get_translation(); + pos += Vector(graphicsRandom.randf(SCREEN_WIDTH), + graphicsRandom.randf(SCREEN_HEIGHT/2)); - float red = static_cast(rand() % 255) / 255.0; - float green = static_cast(rand() % ((int) red*255)) / 255.0; - 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.wav"); - timer.start(((float) rand() / RAND_MAX) + .5); - } + float red = graphicsRandom.randf(1.0); + float green = graphicsRandom.randf(1.0); + //float red = 0.7; + //float green = 0.9; + (void) red; + (void) green; + sector->add_object(std::make_shared(pos, 0, 360, 140, 140, + Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f, + LAYER_FOREGROUND1+1)); + SoundManager::current()->play("sounds/fireworks.wav"); + timer.start(graphicsRandom.randf(1.0, 1.5)); + } } void Fireworks::draw(DrawingContext& ) { } + +/* EOF */