Explosions destroy bricks
[supertux.git] / src / object / brick.cpp
index d054752..8b85905 100644 (file)
 
 #include "audio/sound_manager.hpp"
 #include "badguy/badguy.hpp"
-#include "lisp/list_iterator.hpp"
-#include "object/broken_brick.hpp"
-#include "object/coin.hpp"
-#include "object/flower.hpp"
 #include "object/bouncy_coin.hpp"
-#include "object/growup.hpp"
-#include "object/oneup.hpp"
+#include "object/explosion.hpp"
+#include "object/flower.hpp"
 #include "object/player.hpp"
 #include "object/portable.hpp"
-#include "object/specialriser.hpp"
-#include "object/star.hpp"
 #include "sprite/sprite_manager.hpp"
 #include "supertux/constants.hpp"
-#include "supertux/level.hpp"
-#include "supertux/object_factory.hpp"
 #include "supertux/sector.hpp"
 
-Brick::Brick(const Vector& pos, int data)
-  : Block(sprite_manager->create("images/objects/bonus_block/brick.sprite")), breakable(false),
+Brick::Brick(const Vector& pos, int data, const std::string& spriteName)
+  : Block(sprite_manager->create(spriteName)), breakable(false),
     coin_counter(0)
 {
   bbox.set_pos(pos);
@@ -60,7 +52,7 @@ Brick::collision(GameObject& other, const CollisionHit& hit){
 
   Player* player = dynamic_cast<Player*> (&other);
   if (player) {
-    if (player->does_buttjump) try_break();
+    if (player->does_buttjump) try_break(player);
   }
 
   BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
@@ -69,16 +61,20 @@ Brick::collision(GameObject& other, const CollisionHit& hit){
     // Badguy's bottom has to be below the top of the brick
     // SHIFT_DELTA is required to slide over one tile gaps.
     if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > get_bbox().get_top() + SHIFT_DELTA ) ){
-      try_break();
+      try_break(player);
     }
   }
   Portable* portable = dynamic_cast<Portable*> (&other);
   if(portable) {
     MovingObject* moving = dynamic_cast<MovingObject*> (&other);
     if(moving->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA) {
-      try_break();
+      try_break(player);
     }
   }
+  Explosion* explosion = dynamic_cast<Explosion*> (&other);
+  if(explosion && explosion->hurts()) {
+    try_break(player);
+  }
   return Block::collision(other, hit);
 }