Background can now render three images: Top, Center and Bottom
[supertux.git] / src / object / infoblock.cpp
index 02b2ca2..df6d7ee 100644 (file)
 
 #include <config.h>
 
-#include "infoblock.h"
-#include "game_session.h"
-#include "resources.h"
-#include "sprite/sprite_manager.h"
-#include "object_factory.h"
-#include "lisp/lisp.h"
-#include "audio/sound_manager.h"
-#include "sector.h"
-#include "player.h"
+#include "infoblock.hpp"
+#include "game_session.hpp"
+#include "resources.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "object_factory.hpp"
+#include "lisp/lisp.hpp"
+#include "sector.hpp"
+#include "msg.hpp"
 
 InfoBlock::InfoBlock(const lisp::Lisp& lisp)
-  : Block(sprite_manager->create("infoblock"))
+  : Block(sprite_manager->create("images/objects/bonus_block/infoblock.sprite"))
 {
   Vector pos;
   lisp.get("x", pos.x);
@@ -39,9 +38,11 @@ InfoBlock::InfoBlock(const lisp::Lisp& lisp)
   bbox.set_pos(pos);
 
   if(!lisp.get("message", message)) {
-    std::cerr << "No message in InfoBlock!\n";
+    msg_warning("No message in InfoBlock");
   }
-  ringing = false;
+  stopped = false;
+  ringing = new AmbientSound(get_pos(), 0.5, 300, 1, "sounds/phone.wav");
+  Sector::current()->add_object(ringing);  
 }
 
 InfoBlock::~InfoBlock()
@@ -49,18 +50,14 @@ InfoBlock::~InfoBlock()
 }
 
 void
-InfoBlock::update(float elapsed_time)
-{
-  elapsed_time = 0;
-  if (ringing) sound_manager->play_sound("phone",get_pos(),Sector::current()->player->get_pos());
-}
-
-void
 InfoBlock::hit(Player& )
 {
-  GameSession::current()->display_info_box(message);
-  ringing = false;
   start_bounce();
+  if (!stopped) {
+    ringing->remove_me();
+    stopped = true;
+  }
+  GameSession::current()->display_info_box(message);
 }
 
 IMPLEMENT_FACTORY(InfoBlock, "infoblock")