Major rewrite of scripting support:
[supertux.git] / src / object / block.cpp
index d68b02a..0e9fe52 100644 (file)
@@ -20,6 +20,7 @@
 #include <config.h>
 
 #include "block.hpp"
+#include "msg.hpp"
 
 #include <stdexcept>
 
@@ -51,6 +52,7 @@ Block::Block(Sprite* newsprite)
   : sprite(newsprite), bouncing(false), bounce_dir(0), bounce_offset(0)
 {
   bbox.set_size(32, 32.1);
+  set_group(COLGROUP_STATIC);
   flags |= FLAG_SOLID;
 }
 
@@ -121,7 +123,7 @@ Block::start_bounce()
 //---------------------------------------------------------------------------
 
 BonusBlock::BonusBlock(const Vector& pos, int data)
-  : Block(sprite_manager->create("bonusblock")), object(0)
+  : Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")), object(0)
 {
   bbox.set_pos(pos);
   sprite->set_action("normal");
@@ -132,14 +134,14 @@ BonusBlock::BonusBlock(const Vector& pos, int data)
     case 4: contents = CONTENT_1UP; break;
     case 5: contents = CONTENT_ICEGROW; break;
     default:
-      std::cerr << "Invalid box contents!\n";
+      msg_warning << "Invalid box contents" << std::endl;
       contents = CONTENT_COIN;
       break;
   }          
 }
 
 BonusBlock::BonusBlock(const lisp::Lisp& lisp)
-  : Block(sprite_manager->create("bonusblock"))
+  : Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite"))
 {
   Vector pos;
 
@@ -167,7 +169,7 @@ BonusBlock::BonusBlock(const lisp::Lisp& lisp)
       } else if(contentstring == "custom") {
         contents = CONTENT_CUSTOM;
       } else {
-        std::cerr << "Invalid box contents '" << contentstring << "'.\n";
+        msg_warning << "Invalid box contents '" << contentstring << "'" << std::endl;
       }
     } else {
       if(contents == CONTENT_CUSTOM) {
@@ -177,7 +179,7 @@ BonusBlock::BonusBlock(const lisp::Lisp& lisp)
           throw std::runtime_error(
             "Only MovingObjects are allowed inside BonusBlocks");
       } else {
-        std::cerr << "Invalid element '" << token << "' in bonusblock.\n";
+        msg_warning << "Invalid element '" << token << "' in bonusblock" << std::endl;
       }
     }  
   }
@@ -267,7 +269,7 @@ IMPLEMENT_FACTORY(BonusBlock, "bonusblock");
 //---------------------------------------------------------------------------
 
 Brick::Brick(const Vector& pos, int data)
-  : Block(sprite_manager->create("brick")), breakable(false),
+  : Block(sprite_manager->create("images/objects/bonus_block/brick.sprite")), breakable(false),
     coin_counter(0)
 {
   bbox.set_pos(pos);