fix file lookup
[supertux.git] / src / moving_object.h
index e2691c2..cd6850c 100644 (file)
@@ -1,10 +1,31 @@
-#ifndef __MOVING_OBJECT_H__
-#define __MOVING_OBJECT_H__
+//  $Id: moving_object.h 2295 2005-03-30 01:52:14Z matzebraun $
+//
+//  SuperTux -  A Jump'n Run
+//  Copyright (C) 2004 Matthias Braun <matze@braunis.de
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#ifndef SUPERTUX_MOVING_OBJECT_H
+#define SUPERTUX_MOVING_OBJECT_H
 
-#include "type.h"
 #include "game_object.h"
-#include "vector.h"
-//#include "rectangle.h"
+#include "collision_hit.h"
+#include "math/vector.h"
+#include "math/rectangle.h"
+
+class Sector;
+class CollisionGrid;
 
 /**
  * Base class for all dynamic/moving game objects. This class contains things
@@ -15,25 +36,48 @@ class MovingObject : public GameObject
 public:
   MovingObject();
   virtual ~MovingObject();
-
+  
   /** this function is called when the object collided with any other object
    */
-  virtual void collision(const MovingObject& other_object, 
-          int collision_type) = 0;
-
-  base_type base;
-  base_type old_base;
-
+  virtual HitResponse collision(GameObject& other,
+                                const CollisionHit& hit) = 0;
+  
+  const Vector& get_pos() const
+  {
+    return bbox.p1;
+  }
+  
+  /** returns the bounding box of the Object */
+  const Rectangle& get_bbox() const
+  {
+    return bbox;
+  }
+  
+  const Vector& get_movement() const
+  {
+    return movement;
+  }
+  
+  /** places the moving object at a specific position. Be carefull when
+   * using this function. There are no collision detection checks performed
+   * here so bad things could happen.
+   */
+  virtual void set_pos(const Vector& pos)
+  {
+    bbox.set_pos(pos);
+  }
+  
 protected:
-#if 0 // this will be used in my collision detection rewrite later
-  /// the current position of the object
-  Vector pos;
-  /// the position we want to move until next frame
-  Vector new_pos;
-  /// the bounding box relative to the current position
-  Rectangle bounding_box;
-#endif
+  friend class Sector;
+  friend class CollisionGrid;
+  
+  /** The bounding box of the object (as used for collision detection, this
+   * isn't necessarily the bounding box for graphics)
+   */
+  Rectangle bbox;
+  /** The movement that will happen till next frame
+   */
+  Vector movement;
 };
 
 #endif
-