Background can now render three images: Top, Center and Bottom
[supertux.git] / src / object / platform.cpp
index 6bc64f4..a28ec87 100644 (file)
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //  02111-1307, USA.
-
 #include <config.h>
 
 #include "platform.hpp"
+
+#include "msg.hpp"
 #include "video/drawing_context.hpp"
 #include "resources.hpp"
 #include "player.hpp"
@@ -36,8 +37,8 @@ Platform::Platform(const lisp::Lisp& reader)
   reader.get("x", bbox.p1.x);
   reader.get("y", bbox.p1.y);
   reader.get("type", type);
-  reader.get("use_path", use_path);
-  sprite = sprite_manager->create("platform");
+  reader.get("path", use_path);
+  sprite = sprite_manager->create("images/objects/flying_platform/platform.sprite");
   sprite->set_action(type);
   bbox.set_size(sprite->get_width(), sprite->get_height());
 
@@ -45,7 +46,11 @@ Platform::Platform(const lisp::Lisp& reader)
 
   path = Path::GetByName(use_path);
 
-  path_offset = bbox.p1 - path->GetStart();
+  if (path == NULL) {
+    msg_warning("Path \"" << use_path << "\" for moving platform not found! Make sure that the name is spelled correctly and that the path is initialized before the platform in the level file!");
+  }
+
+  path_offset = bbox.p1;
 }
 
 Platform::~Platform()
@@ -53,6 +58,9 @@ Platform::~Platform()
   delete sprite;
 }
 
+//TODO: Squish Tux when standing between platform and solid tile/object
+//      Improve collision handling
+//      Move all MovingObjects lying on the platform instead of only the player
 HitResponse
 Platform::collision(GameObject& other, const CollisionHit& hit)
 {
@@ -66,12 +74,13 @@ Platform::collision(GameObject& other, const CollisionHit& hit)
   if(other.get_flags() & FLAG_SOLID) {
     //Collision with a solid tile
     //does nothing, because the movement vector isn't used at the moment
+    return ABORT_MOVE;
   }
   return FORCE_MOVE;
 }
 
 void
-Platform::update(float elapsed_time)
+Platform::update(float )
 {
   set_pos(path->GetPosition() + path_offset);
 }