Cleaned up some junk in bonus_block.
authorLMH <lmh.0013@gmail.com>
Mon, 26 Aug 2013 18:49:03 +0000 (08:49 -1000)
committerLMH <lmh.0013@gmail.com>
Mon, 26 Aug 2013 18:58:15 +0000 (08:58 -1000)
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.

data/images/objects/bonus_block/bonus-levelflip.png [new file with mode: 0644]
data/images/tiles.strf
src/badguy/goldbomb.cpp
src/object/bonus_block.cpp
src/object/bonus_block.hpp
src/object/coin.cpp
src/object/coin_explode.cpp
src/object/coin_explode.hpp

diff --git a/data/images/objects/bonus_block/bonus-levelflip.png b/data/images/objects/bonus_block/bonus-levelflip.png
new file mode 100644 (file)
index 0000000..3e814a0
Binary files /dev/null and b/data/images/objects/bonus_block/bonus-levelflip.png differ
index 5a57eaf..48ecece 100644 (file)
 ;;    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"
   )
   (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")
     (image "tiles/pole/diagonals.png")
   )
 
-;; next-id: 3037
+;; next-id: 3038
 )
index f87f605..59911a7 100644 (file)
@@ -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();
index 3f58dc5..1baeaef 100644 (file)
@@ -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;
     }
index 5c4590c..471313a 100644 (file)
@@ -41,8 +41,6 @@ public:
     CONTENT_SCRIPT,
     CONTENT_LIGHT,
     CONTENT_TRAMPOLINE,
-    CONTENT_PORTTRAMPOLINE,
-    CONTENT_ROCK,
     CONTENT_RAIN,
     CONTENT_EXPLODE
   };
index 86e4dd8..3b0efc1 100644 (file)
@@ -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());
   }
 }
 
index 35bca7d..dad8962 100644 (file)
@@ -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) 
 {
 }
 
index 227215c..2efde27 100644 (file)
 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