00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00049
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