X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Ffireworks.cpp;h=d3037ea6f65ae95dc6492b18b3524c5ef4246f81;hb=04a3157ef478169b5a3fc05dae00ed6ee6a1fae2;hp=68ac1e0e01542cc5b51ee37ae224aee861ff5696;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/object/fireworks.cpp b/src/object/fireworks.cpp index 68ac1e0e0..d3037ea6f 100644 --- a/src/object/fireworks.cpp +++ b/src/object/fireworks.cpp @@ -27,10 +27,12 @@ #include "main.hpp" #include "video/drawing_context.hpp" #include "audio/sound_manager.hpp" +#include "random_generator.hpp" Fireworks::Fireworks() { - timer.start(.2); + timer.start(.2f); + 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)); - float red = static_cast(rand() % 255) / 255.0; - float green = static_cast(rand() % ((int) red*255)) / 255.0; + 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, + Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f, LAYER_FOREGROUND1+1)); sound_manager->play("sounds/fireworks.wav"); - timer.start(((float) rand() / RAND_MAX) + .5); + timer.start(systemRandom.randf(1.0, 1.5)); } }