| 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.hpp" |
| 20 | #include "object/coin.hpp" |
| 21 | #include "supertux/sector.hpp" |
| 22 | |
| 23 | CoinExplode::CoinExplode(const Vector& pos) : |
| 24 | position(pos) |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | void |
| 29 | CoinExplode::update(float ) |
| 30 | { |
| 31 | float mag = 100.0f; // madnitude that coins are to be thrown |
| 32 | float rand = 30.0f; // max variation to be subtracted from magnitide |
| 33 | |
| 34 | Sector::get().add<HeavyCoin>(position, Vector(2.5, -4.5) * (mag - gameRandom.randf(rand))); |
| 35 | Sector::get().add<HeavyCoin>(position, Vector(2, -5) * (mag - gameRandom.randf(rand))); |
| 36 | Sector::get().add<HeavyCoin>(position, Vector(1.5, -5.5) * (mag - gameRandom.randf(rand))); |
| 37 | Sector::get().add<HeavyCoin>(position, Vector(1, -6) * (mag+gameRandom.randf(rand))); |
| 38 | Sector::get().add<HeavyCoin>(position, Vector(0.5, -6.5) * (mag - gameRandom.randf(rand))); |
| 39 | Sector::get().add<HeavyCoin>(position, Vector(-2.5, -4.5) * (mag - gameRandom.randf(rand))); |
| 40 | Sector::get().add<HeavyCoin>(position, Vector(-2, -5) * (mag - gameRandom.randf(rand))); |
| 41 | Sector::get().add<HeavyCoin>(position, Vector(-1.5, -5.5) * (mag - gameRandom.randf(rand))); |
| 42 | Sector::get().add<HeavyCoin>(position, Vector(-1, -6) * (mag+gameRandom.randf(rand))); |
| 43 | Sector::get().add<HeavyCoin>(position, Vector(-0.5, -6.5) * (mag - gameRandom.randf(rand))); |
| 44 | |
| 45 | remove_me(); |
| 46 | } |
| 47 | |
| 48 | void |
| 49 | CoinExplode::draw(DrawingContext &) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | /* EOF */ |
| 54 | |