Causes ten coins to be hurled through the air as an alternative to coin rain in covered areas such as cave levels. These coins are included in the level stats. Testable in test/bonusblock.stl.
;; src/tile.cpp, unisolid is 3 not 2
(supertux-tiles
(tile
+ (id 2948)
+ (images
+ "objects/bonus_block/full-0.png"
+ "objects/bonus_block/full-1.png"
+ "objects/bonus_block/full-2.png"
+ "objects/bonus_block/full-3.png"
+ "objects/bonus_block/full-4.png"
+ "objects/bonus_block/full-3.png"
+ "objects/bonus_block/full-2.png"
+ "objects/bonus_block/full-1.png"
+ "objects/bonus_block/full-0.png"
+ "objects/bonus_block/full-0.png"
+ "objects/bonus_block/full-0.png"
+ )
+ (solid #t)
+ (fullbox #t)
+ (next-tile 84)
+ (editor-images "objects/bonus_block/bonus-explode.png")
+ (data 11)
+ (fps 15)
+ )
+
+ (tile
(id 2947)
(images
"objects/bonus_block/full-0.png"
(data 10)
(fps 15)
)
-
+
(tile
(id 2946)
(images
(data 9)
(fps 15)
)
-
+
(tile
(id 2945)
(images
(data 8)
(fps 15)
)
-
+
(tile
(id 2944)
(images
(data 7)
(fps 15)
)
-
+
(tile
(id 2943)
(images
(data 6)
(fps 15)
)
-
+
(tilegroup
(name "Pipe: Green")
(tiles
)
(tilegroup
(name "Block")
- (tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 44 83 2947 84 102 140 103 104 105 112 128 2943 2944 2945 2946 1311 2153)
+ (tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 44 83 2947 2948 84 102 140 103 104 105 112 128 2943 2944 2945 2946 1311 2153)
)
(tilegroup
(name "Background")
(image "tiles/snow/slope-upper.png" )
)
-;; next-id: 2948
+;; next-id: 2949
)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 384
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 416
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 448
-0 0 0 0 2946 0 0 0 2947 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 480
+0 0 0 0 2946 0 0 0 2947 0 0 0 2948 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 480
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 512
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 544
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 576
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 864
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 896
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 928
- ))
-
- (bonusblock
- (x 256 )
- (y 640 )
- (contents "coin" )
- (count 3 )
- )
-
+ ))
+
+ (bonusblock
+ (x 256 )
+ (y 640 )
+ (contents "coin" )
+ (count 3 )
+ )
+
(bonusblock
(x 384 )
(y 640 )
#include "object/broken_brick.hpp"
#include "object/flower.hpp"
#include "object/bouncy_coin.hpp"
+#include "object/coin_explode.hpp"
#include "object/coin_rain.hpp"
#include "object/growup.hpp"
#include "object/oneup.hpp"
case 8: contents = CONTENT_PORTTRAMPOLINE; break;
case 9: contents = CONTENT_ROCK; break;
case 10: contents = CONTENT_RAIN; break;
+ case 11: contents = CONTENT_EXPLODE; break;
default:
log_warning << "Invalid box contents" << std::endl;
contents = CONTENT_COIN;
contents = CONTENT_ROCK;
} else if(contentstring == "rain") {
contents = CONTENT_RAIN;
+ } else if(contentstring == "explode") {
+ contents = CONTENT_EXPLODE;
} else {
log_warning << "Invalid box contents '" << contentstring << "'" << std::endl;
}
hit_counter = 1; // multiple hits of coin rain is not allowed
Sector::current()->add_object(new CoinRain(get_pos(), true));
sound_manager->play("sounds/upgrade.wav");
+ break;
+ }
+ case CONTENT_EXPLODE:
+ {
+ hit_counter = 1; // multiple hits of coin explode is not allowed
+ Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, -40), 1));
+ sound_manager->play("sounds/upgrade.wav");
+ break;
}
}
CONTENT_TRAMPOLINE,
CONTENT_PORTTRAMPOLINE,
CONTENT_ROCK,
- CONTENT_RAIN
+ CONTENT_RAIN,
+ CONTENT_EXPLODE
};
protected:
{
if(hit.bottom) {
physic.set_velocity_y(0);
+ physic.set_velocity_x(0);
}
if(hit.right || hit.left) {
physic.set_velocity_x(-physic.get_velocity_x());
}
+ if(hit.top) {
+ physic.set_velocity_y(0);
+ }
}
/* EOF */
--- /dev/null
+// CoinExplode - several coins are hurled through the air
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "object/coin_explode.hpp"
+
+#include "math/random_generator.hpp"
+#include "object/coin.hpp"
+#include "supertux/sector.hpp"
+
+CoinExplode::CoinExplode(const Vector& pos, const int vert) :
+ position(pos),
+ y_velocity_weight(vert) // should generally be +/- 1 to send coins up or down respectively
+{
+}
+
+void
+CoinExplode::update(float )
+{
+ int mag = 100; // madnitude that coins are to be thrown
+ int rand = 30; // max variation to be subtracted from magnitide
+
+ //TODO: this needs its own snazzy sound
+ Sector::current()->add_object(new HeavyCoin(position, Vector (2.5,-4.5)*(mag-gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (2,-5)*(mag-gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (1.5,-5.5)*(mag-gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (1,-6)*(mag+gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (0.5,-6.5)*(mag-gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (-2.5,-4.5)*(mag-gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (-2,-5)*(mag-gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (-1.5,-5.5)*(mag-gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (-1,-6)*(mag+gameRandom.rand(rand))));
+ Sector::current()->add_object(new HeavyCoin(position, Vector (-0.5,-6.5)*(mag-gameRandom.rand(rand))));
+
+ remove_me();
+}
+
+void
+CoinExplode::draw(DrawingContext &)
+{
+}
+
+/* EOF */
--- /dev/null
+// CoinExplode - several coins are hurled through the air
+// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_OBJECT_COIN_EXPLODE_HPP
+#define HEADER_SUPERTUX_OBJECT_COIN_EXPLODE_HPP
+
+#include <memory>
+
+#include "math/vector.hpp"
+#include "supertux/game_object.hpp"
+
+class CoinExplode : public GameObject
+{
+public:
+ CoinExplode(const Vector& pos, const int vert);
+ virtual void update(float elapsed_time);
+ virtual void draw(DrawingContext& context);
+
+private:
+ Vector position;
+ int y_velocity_weight;
+};
+
+#endif
+
+/* EOF */
} else if (block->contents == BonusBlock::CONTENT_RAIN) {
total_coins += 10;
continue;
+ } else if (block->contents == BonusBlock::CONTENT_EXPLODE) {
+ total_coins += 10;
+ continue;
}
#if 0
// FIXME: do we want this? q.v. src/object/oneup.cpp
#include "object/candle.hpp"
#include "object/cloud_particle_system.hpp"
#include "object/coin.hpp"
+#include "object/coin_explode.hpp"
#include "object/coin_rain.hpp"
#include "object/comet_particle_system.hpp"
#include "object/decal.hpp"