New BonusBlock content: 'explode' - a coin explosion.
[supertux.git] / src / object / coin_explode.cpp
1 //  CoinExplode - several coins are hurled through the air
2 //  Copyright (C) 2013 LMH <lmh.0013@gmail.com>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #include "object/coin_explode.hpp"
18
19 #include "math/random_generator.hpp"
20 #include "object/coin.hpp"
21 #include "supertux/sector.hpp"
22
23 CoinExplode::CoinExplode(const Vector& pos, const int vert) :
24   position(pos), 
25   y_velocity_weight(vert) // should generally be +/- 1 to send coins up or down respectively
26 {
27 }
28
29 void
30 CoinExplode::update(float )
31 {
32   int mag = 100; // madnitude that coins are to be thrown
33   int rand = 30; // max variation to be subtracted from magnitide
34
35   //TODO: this needs its own snazzy sound
36   Sector::current()->add_object(new HeavyCoin(position, Vector (2.5,-4.5)*(mag-gameRandom.rand(rand))));
37   Sector::current()->add_object(new HeavyCoin(position, Vector (2,-5)*(mag-gameRandom.rand(rand))));
38   Sector::current()->add_object(new HeavyCoin(position, Vector (1.5,-5.5)*(mag-gameRandom.rand(rand))));
39   Sector::current()->add_object(new HeavyCoin(position, Vector (1,-6)*(mag+gameRandom.rand(rand))));
40   Sector::current()->add_object(new HeavyCoin(position, Vector (0.5,-6.5)*(mag-gameRandom.rand(rand))));
41   Sector::current()->add_object(new HeavyCoin(position, Vector (-2.5,-4.5)*(mag-gameRandom.rand(rand))));
42   Sector::current()->add_object(new HeavyCoin(position, Vector (-2,-5)*(mag-gameRandom.rand(rand))));
43   Sector::current()->add_object(new HeavyCoin(position, Vector (-1.5,-5.5)*(mag-gameRandom.rand(rand))));
44   Sector::current()->add_object(new HeavyCoin(position, Vector (-1,-6)*(mag+gameRandom.rand(rand))));
45   Sector::current()->add_object(new HeavyCoin(position, Vector (-0.5,-6.5)*(mag-gameRandom.rand(rand))));
46
47   remove_me();
48 }
49
50 void
51 CoinExplode::draw(DrawingContext &)
52 {
53 }
54
55 /* EOF */