fix tiles being 1 pixel off their correct position
[supertux.git] / src / camera.h
index aaa8e19..b64e71d 100644 (file)
 #ifndef __VIEWPORT_H__
 #define __VIEWPORT_H__
 
+#include <vector>
 #include "vector.h"
 #include "game_object.h"
 #include "serializable.h"
+#include <cassert>
 
 class LispReader;
 class Player;
@@ -33,36 +35,31 @@ public:
   Camera(Player* player = 0, Level* level = 0);
   virtual ~Camera();
 
-  /** transforms a coordinate in world space to screen space.
-   * Basically you have to apply this function to each coordinate that you want
-   * to display on screen.
-   */
-  Vector world2screen(const Vector& worldpos) const
-  {
-    return worldpos - translation;                   
-  }                                                  
-
   /// parse camera mode from lisp file
-  void parse_camera(LispReader& reader);
+  void read(LispReader& reader);
   /// write camera mode to a lisp file
   virtual void write(LispWriter& writer);
 
-  /** returns the current translation (=scroll) vector of the viewport */
-  const Vector& get_translation() const
-  { return translation; }
-  /** set the curren translation vector of the viewport */
-  void set_translation(const Vector& translation);
+  /** @deprecated@ */
+  const Vector& get_translation() const;
 
   virtual void action(float elapsed_time);
 
+  virtual void draw(DrawingContext& context)
+  {
+    (void) context;
+  }
+
   enum CameraMode
   {
     NORMAL, AUTOSCROLL, MANUAL
   };
+  CameraMode mode;
 
 private:
   void scroll_normal(float elapsed_time);
   void scroll_autoscroll(float elapsed_time);
+  void keep_in_bounds();
 
   enum LeftRightScrollChange
   {
@@ -73,8 +70,21 @@ private:
 
   Player* player;
   Level* level;
-  CameraMode mode;
+
+  // normal mode
+  bool do_backscrolling;
   LeftRightScrollChange scrollchange;
+
+  // autoscroll mode
+  class ScrollPoint {
+  public:
+    Vector position;
+    float speed;
+  };
+  std::vector<ScrollPoint> scrollpoints;
+  size_t auto_idx;
+  float auto_t;
+  Vector current_dir;
 };
 
 #endif