From: LMH Date: Mon, 26 Aug 2013 18:49:03 +0000 (-1000) Subject: Cleaned up some junk in bonus_block. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1e6e54ca5a696961181861837f2c2a284c400deb;p=supertux.git Cleaned up some junk in bonus_block. Removed some unnecessary switches to reduce the amount of code. Star and Tux dolls now make a noise when leaving the bonus block. Removed unused variable from coin_explode. Heavy coins now bounce once when hitting the ground at high velocity and reflect their y velocity when hitting the bottome of something. Made it easy for the editor to place bonus blocks with the flip level potions. --- diff --git a/data/images/objects/bonus_block/bonus-levelflip.png b/data/images/objects/bonus_block/bonus-levelflip.png new file mode 100644 index 000000000..3e814a041 Binary files /dev/null and b/data/images/objects/bonus_block/bonus-levelflip.png differ diff --git a/data/images/tiles.strf b/data/images/tiles.strf index 5a57eaf6e..48ecece66 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 3037) + (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-levelflip.png") + (data 12) + (fps 15) + ) + + (tile (id 2948) (images "objects/bonus_block/full-0.png" @@ -601,7 +624,7 @@ ) (tilegroup (name "Block") - (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) + (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 3037 2943 2944 2945 2946 1311 2153) ) (tilegroup (name "Background") @@ -3993,5 +4016,5 @@ (image "tiles/pole/diagonals.png") ) -;; next-id: 3037 +;; next-id: 3038 ) diff --git a/src/badguy/goldbomb.cpp b/src/badguy/goldbomb.cpp index f87f6059b..59911a7be 100644 --- a/src/badguy/goldbomb.cpp +++ b/src/badguy/goldbomb.cpp @@ -160,7 +160,7 @@ GoldBomb::kill_fall() if(is_valid()) { remove_me(); Sector::current()->add_object(new Explosion(get_bbox().get_middle())); - Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, -40), 1)); + Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, -40))); } run_dead_script(); diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index 3f58dc526..1baeaef57 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -59,11 +59,20 @@ BonusBlock::BonusBlock(const Vector& pos, int data) : sound_manager->preload("sounds/switch.ogg"); lightsprite=Surface::create("/images/objects/lightmap_light/bonusblock_light.png"); break; - case 7: contents = CONTENT_TRAMPOLINE; break; - case 8: contents = CONTENT_PORTTRAMPOLINE; break; - case 9: contents = CONTENT_ROCK; break; + case 7: contents = CONTENT_TRAMPOLINE; + //object = new Trampoline(get_pos(), false); //needed if this is to be moved to custom + break; + case 8: contents = CONTENT_CUSTOM; + object = new Trampoline(get_pos(), true); + break; + case 9: contents = CONTENT_CUSTOM; + object = new Rock(get_pos(), "images/objects/rock/rock.sprite"); + break; case 10: contents = CONTENT_RAIN; break; case 11: contents = CONTENT_EXPLODE; break; + case 12: contents = CONTENT_CUSTOM; + object = new PowerUp(get_pos(), "images/powerups/potions/red-potion.sprite"); + break; default: log_warning << "Invalid box contents" << std::endl; contents = CONTENT_COIN; @@ -93,7 +102,7 @@ BonusBlock::BonusBlock(const Reader& lisp) : sprite = sprite_manager->create(sprite_name); } else if(token == "count") { iter.value()->get(hit_counter); - } else if(token == "script") { // use when bonusblock is to contain ONLY a script + } else if(token == "script") { iter.value()->get(script); } else if(token == "contents") { std::string contentstring; @@ -110,17 +119,13 @@ BonusBlock::BonusBlock(const Reader& lisp) : contents = CONTENT_1UP; } else if(contentstring == "custom") { contents = CONTENT_CUSTOM; - } else if(contentstring == "script") { + } else if(contentstring == "script") { // use when bonusblock is to contain ONLY a script contents = CONTENT_SCRIPT; } else if(contentstring == "light") { contents = CONTENT_LIGHT; sound_manager->preload("sounds/switch.ogg"); } else if(contentstring == "trampoline") { contents = CONTENT_TRAMPOLINE; - } else if(contentstring == "porttrampoline") { - contents = CONTENT_PORTTRAMPOLINE; - } else if(contentstring == "rock") { - contents = CONTENT_ROCK; } else if(contentstring == "rain") { contents = CONTENT_RAIN; } else if(contentstring == "explode") { @@ -248,12 +253,14 @@ BonusBlock::try_open(Player *player) case CONTENT_STAR: { sector->add_object(new Star(get_pos() + Vector(0, -32), direction)); + sound_manager->play("sounds/upgrade.wav"); break; } case CONTENT_1UP: { sector->add_object(new OneUp(get_pos(), direction)); + sound_manager->play("sounds/upgrade.wav"); break; } @@ -285,22 +292,6 @@ BonusBlock::try_open(Player *player) sound_manager->play("sounds/upgrade.wav"); break; } - case CONTENT_PORTTRAMPOLINE: - { - SpecialRiser* riser = new SpecialRiser(get_pos(), new Trampoline(get_pos(), true)); - sector->add_object(riser); - sound_manager->play("sounds/upgrade.wav"); - break; - } - case CONTENT_ROCK: - { - SpecialRiser* riser = new SpecialRiser(get_pos(), - new Rock(get_pos(), "images/objects/rock/rock.sprite")); - sector->add_object(riser); - sound_manager->play("sounds/upgrade.wav"); - break; - } - case CONTENT_RAIN: { hit_counter = 1; // multiple hits of coin rain is not allowed @@ -311,7 +302,7 @@ BonusBlock::try_open(Player *player) 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)); + Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, -40))); sound_manager->play("sounds/upgrade.wav"); break; } @@ -385,18 +376,20 @@ BonusBlock::try_drop(Player *player) case CONTENT_STAR: { sector->add_object(new Star(get_pos() + Vector(0, 32), direction)); + sound_manager->play("sounds/upgrade.wav"); break; } case CONTENT_1UP: { sector->add_object(new OneUp(get_pos(), DOWN)); + sound_manager->play("sounds/upgrade.wav"); break; } case CONTENT_CUSTOM: { - //TODO: confirm this works + //TODO: non-portable trampolines could be moved to CONTENT_CUSTOM, but they should not drop object->set_pos(get_pos() + Vector(0, 32)); sector->add_object(object); object = 0; @@ -417,19 +410,6 @@ BonusBlock::try_drop(Player *player) try_open(player); break; } - case CONTENT_PORTTRAMPOLINE: - { - Sector::current()->add_object(new Trampoline(get_pos() + Vector (0, 32), true)); - sound_manager->play("sounds/upgrade.wav"); - break; - } - case CONTENT_ROCK: - { - Sector::current()->add_object(new Rock(get_pos() + Vector (0, 32), "images/objects/rock/rock.sprite")); - sound_manager->play("sounds/upgrade.wav"); - break; - } - case CONTENT_RAIN: { try_open(player); @@ -438,7 +418,7 @@ BonusBlock::try_drop(Player *player) 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)); + Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, 40))); sound_manager->play("sounds/upgrade.wav"); break; } diff --git a/src/object/bonus_block.hpp b/src/object/bonus_block.hpp index 5c4590c6a..471313aa1 100644 --- a/src/object/bonus_block.hpp +++ b/src/object/bonus_block.hpp @@ -41,8 +41,6 @@ public: CONTENT_SCRIPT, CONTENT_LIGHT, CONTENT_TRAMPOLINE, - CONTENT_PORTTRAMPOLINE, - CONTENT_ROCK, CONTENT_RAIN, CONTENT_EXPLODE }; diff --git a/src/object/coin.cpp b/src/object/coin.cpp index 86e4dd8aa..3b0efc158 100644 --- a/src/object/coin.cpp +++ b/src/object/coin.cpp @@ -208,8 +208,12 @@ HeavyCoin::collision_solid(const CollisionHit& hit) if(hit.bottom) { if(physic.get_velocity_y() > clink_threshold) sound_manager->play("sounds/coin.wav"); - physic.set_velocity_y(0); - physic.set_velocity_x(0); + if(physic.get_velocity_y() > 200) {// lets some coins bounce + physic.set_velocity_y(-99); + }else{ + physic.set_velocity_y(0); + physic.set_velocity_x(0); + } } if(hit.right || hit.left) { if(physic.get_velocity_x() > clink_threshold || physic.get_velocity_x() < clink_threshold) @@ -219,7 +223,7 @@ HeavyCoin::collision_solid(const CollisionHit& hit) if(hit.top) { if(physic.get_velocity_y() < clink_threshold) sound_manager->play("sounds/coin.wav"); - physic.set_velocity_y(0); + physic.set_velocity_y(-physic.get_velocity_y()); } } diff --git a/src/object/coin_explode.cpp b/src/object/coin_explode.cpp index 35bca7db2..dad8962fa 100644 --- a/src/object/coin_explode.cpp +++ b/src/object/coin_explode.cpp @@ -20,9 +20,8 @@ #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 +CoinExplode::CoinExplode(const Vector& pos) : + position(pos) { } diff --git a/src/object/coin_explode.hpp b/src/object/coin_explode.hpp index 227215cb9..2efde279f 100644 --- a/src/object/coin_explode.hpp +++ b/src/object/coin_explode.hpp @@ -25,13 +25,12 @@ class CoinExplode : public GameObject { public: - CoinExplode(const Vector& pos, const int vert); + CoinExplode(const Vector& pos); virtual void update(float elapsed_time); virtual void draw(DrawingContext& context); private: Vector position; - int y_velocity_weight; }; #endif