From 1e6e54ca5a696961181861837f2c2a284c400deb Mon Sep 17 00:00:00 2001 From: LMH Date: Mon, 26 Aug 2013 08:49:03 -1000 Subject: [PATCH] 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. --- .../images/objects/bonus_block/bonus-levelflip.png | Bin 0 -> 2484 bytes data/images/tiles.strf | 27 ++++++++- src/badguy/goldbomb.cpp | 2 +- src/object/bonus_block.cpp | 62 +++++++-------------- src/object/bonus_block.hpp | 2 - src/object/coin.cpp | 10 +++- src/object/coin_explode.cpp | 5 +- src/object/coin_explode.hpp | 3 +- 8 files changed, 57 insertions(+), 54 deletions(-) create mode 100644 data/images/objects/bonus_block/bonus-levelflip.png 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 0000000000000000000000000000000000000000..3e814a04117bbcbb368a26d143525cb55e6c3bc7 GIT binary patch literal 2484 zcmV;l2}|~gP)WFU8GbZ8()Nlj2>E@cM*00|gLL_t(o!?l-da9vdy zhM#rW`&^Qf=F+rDX(@#^OhW_+Wy#SPSaBT<(fHj_BvA95}ZC(bcFmr$Dw`V)TuZ<@jcJJ%pzN|Fs^A-5thjyS~fn=hb)({2+oL`(h$?o zn5v`sg5?0@(F~Q~#8i=~lE*|Q!!Pc>mAIdya^zi61+bzcyzYtJY+V%N@;XVqj)F=h zu}yUCO1S+KTNoQ1`JY9;_}AT}QYioq`+_4=9*3qJ4j&(-`$UFg2M#j+%%gBW4&|E}cT@bc z=KyOuu3*ZCAy@ErQPESeF-Fl%4e@g?nFXs@(GhNX{4ZS99Aj0Dz$k$X6(gSD?YvKS zUU4v+XV-%}X`PqkNO}@GnIdVXn07VUvLWY$6g@cZEMWPC?d;k2CPyz^#{emgmkozp z$v=uP?n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Ra*7*fvL!Nj{xOU`hqLU+Kb@ zJ`G6=V&d!o?4CVrS+WF#h^o$HVE=yDyEm%ZnCSOhE^$^XDb18pxwDL5Nh6f;7l-fi@wc3Oz3pTyJmm4d6HtkRX_S4EsV52th?D z+!;F#0Z#~gAy_IUhw=qnqiK{rwel1nm<$AtFpL>N&Wmmy&SqJA^k`J6?}OG+M?5bQ zUZpadq@)xE$ZJhmDLg5u2!RSiB#;aOGN!uyCXJ-YD^)3&@L(_uIpDyU8!~lCCwnrP zi1$n;Qhg9WsT7HBVq!LVQEOZ&ag<`(vT&p%0D>6+$si!*`|Jw>*01kmI)H4+<5d}O*jcWojS8So_jpw=V@SFVc z;6YOHI2eQL`{XT)g4TFaQc{YFlvI?Wq!eYP@P#0pNgg+bbfv=YU6;??aR>D+EsSM+ zj<_KdJ#dQ=1y0FlV$#EQtIz5FJ0BvOsO1)8=qr^7D;0`DP}G`?ZIh128A>D=iN~3+ zZHh|a&Ir*6LChEqluGO>7FoS!EnoTKos1cHCu=yI4?!lYBJ3N>azaKT(Iud+m1et! z-fujKyX!t~N%!%2;F^=$)R<_i&DgLEL&VJ1)5cKrJbqg!aL{qseBE{2bMFpvf#6@+ zfPIq{rYd1X>8U59ww;gCXEYcM#)8B=8WW1ingo}>@@vAEpC%|3*q{_Em7-Q_&a*6B zDJh2`LqWh$5YXd!^m`r)T3fk&`wlK$e-+b4a%9@$xnYNwhf1WUeE9B-b5BN-hx>`o zUrK{a5C)P_r_AIOK!N@XZlHGA2K4c6_8i#FOa1#J2Rv<9$y!?1T*-!yUcZ4chXyf2}-YG8) ywNN)ds;E?+{W%PLEI*oiIswD`;pp3Qa{dRyi8-CeM8r)10000add_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 -- 2.11.0