changed worldmap format a bit to be more consistent with level format
[supertux.git] / src / object / fireworks.cpp
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20 #include <config.h>
21
22 #include "fireworks.h"
23 #include "resources.h"
24 #include "sector.h"
25 #include "camera.h"
26 #include "gameobjs.h"
27 #include "main.h"
28 #include "video/drawing_context.h"
29 #include "audio/sound_manager.h"
30
31 Fireworks::Fireworks()
32 {
33   timer.start(.2);
34 }
35
36 Fireworks::~Fireworks()
37 {
38 }
39
40 void
41 Fireworks::update(float )
42 {
43     if(timer.check()) {
44         Sector* sector = Sector::current();
45         Vector pos = sector->camera->get_translation();
46         pos += Vector(SCREEN_WIDTH * ((float) rand() / RAND_MAX),
47                       SCREEN_HEIGHT/2 * ((float) rand() / RAND_MAX));
48
49         int red = rand() % 255;
50         int green = rand() % red;
51         sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
52                 Vector(0, 0), 45, Color(red, green, 0), 3, 1.3,
53                 LAYER_FOREGROUND1+1));
54         sound_manager->play_sound("fireworks");
55         timer.start(((float) rand() / RAND_MAX) + .5);
56     }
57 }
58
59 void
60 Fireworks::draw(DrawingContext& )
61 {
62 }