From: LMH Date: Sat, 13 Jul 2013 21:22:45 +0000 (-1000) Subject: New BonusBlock content: 'explode' - a coin explosion. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4f0d26aa598a1fd471f22767cedea4f179f8908b;p=supertux.git New BonusBlock content: 'explode' - a coin explosion. 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. --- diff --git a/data/images/objects/bonus_block/bonus-explode.png b/data/images/objects/bonus_block/bonus-explode.png new file mode 100644 index 000000000..cdc07f9aa Binary files /dev/null and b/data/images/objects/bonus_block/bonus-explode.png differ diff --git a/data/images/tiles.strf b/data/images/tiles.strf index 6f3015144..8661a3bbd 100644 --- a/data/images/tiles.strf +++ b/data/images/tiles.strf @@ -15,6 +15,29 @@ ;; 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" @@ -36,7 +59,7 @@ (data 10) (fps 15) ) - + (tile (id 2946) (images @@ -59,7 +82,7 @@ (data 9) (fps 15) ) - + (tile (id 2945) (images @@ -82,7 +105,7 @@ (data 8) (fps 15) ) - + (tile (id 2944) (images @@ -105,7 +128,7 @@ (data 7) (fps 15) ) - + (tile (id 2943) (images @@ -128,7 +151,7 @@ (data 6) (fps 15) ) - + (tilegroup (name "Pipe: Green") (tiles @@ -638,7 +661,7 @@ ) (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") @@ -3938,5 +3961,5 @@ (image "tiles/snow/slope-upper.png" ) ) -;; next-id: 2948 +;; next-id: 2949 ) diff --git a/data/levels/test/bonusblock.stl b/data/levels/test/bonusblock.stl index 746425071..c8510ca24 100755 --- a/data/levels/test/bonusblock.stl +++ b/data/levels/test/bonusblock.stl @@ -30,7 +30,7 @@ 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 @@ -45,15 +45,15 @@ 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 ) diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index fa94cb19c..36d755812 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -22,6 +22,7 @@ #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" @@ -61,6 +62,7 @@ BonusBlock::BonusBlock(const Vector& pos, int data) : 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; @@ -120,6 +122,8 @@ BonusBlock::BonusBlock(const Reader& lisp) : 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; } @@ -301,6 +305,14 @@ BonusBlock::try_open(Player *player) 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; } } diff --git a/src/object/bonus_block.hpp b/src/object/bonus_block.hpp index 127965e6c..4e3be522e 100644 --- a/src/object/bonus_block.hpp +++ b/src/object/bonus_block.hpp @@ -42,7 +42,8 @@ public: CONTENT_TRAMPOLINE, CONTENT_PORTTRAMPOLINE, CONTENT_ROCK, - CONTENT_RAIN + CONTENT_RAIN, + CONTENT_EXPLODE }; protected: diff --git a/src/object/coin.cpp b/src/object/coin.cpp index a1eea594f..c87c9384f 100644 --- a/src/object/coin.cpp +++ b/src/object/coin.cpp @@ -194,10 +194,14 @@ HeavyCoin::collision_solid(const CollisionHit& hit) { 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 */ diff --git a/src/object/coin_explode.cpp b/src/object/coin_explode.cpp new file mode 100644 index 000000000..e1853cf73 --- /dev/null +++ b/src/object/coin_explode.cpp @@ -0,0 +1,55 @@ +// CoinExplode - several coins are hurled through the air +// Copyright (C) 2013 LMH +// +// 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 . + +#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 */ diff --git a/src/object/coin_explode.hpp b/src/object/coin_explode.hpp new file mode 100644 index 000000000..227215cb9 --- /dev/null +++ b/src/object/coin_explode.hpp @@ -0,0 +1,39 @@ +// CoinExplode - several coins are hurled through the air +// Copyright (C) 2013 LMH +// +// 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 . + +#ifndef HEADER_SUPERTUX_OBJECT_COIN_EXPLODE_HPP +#define HEADER_SUPERTUX_OBJECT_COIN_EXPLODE_HPP + +#include + +#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 */ diff --git a/src/supertux/level.cpp b/src/supertux/level.cpp index e63b4a664..fbd16c3bb 100644 --- a/src/supertux/level.cpp +++ b/src/supertux/level.cpp @@ -206,6 +206,9 @@ Level::get_total_coins() } 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 diff --git a/src/supertux/object_factory.cpp b/src/supertux/object_factory.cpp index 318389fa1..42fe3445a 100644 --- a/src/supertux/object_factory.cpp +++ b/src/supertux/object_factory.cpp @@ -86,6 +86,7 @@ #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"