X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcamera.h;h=07656260d064fa88c6c914f9fecffba3e382e319;hb=f41a5719a2dc1a50674c69fa511c38a152cc4b03;hp=453a06a8fff9eb5649d14ba9faf3aa5e990bb73d;hpb=a7e1aac92757aa9fa50863fb9abc683cc5388b1d;p=supertux.git diff --git a/src/camera.h b/src/camera.h index 453a06a8f..07656260d 100644 --- a/src/camera.h +++ b/src/camera.h @@ -16,47 +16,56 @@ // 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 __VIEWPORT_H__ -#define __VIEWPORT_H__ + +#ifndef SUPERTUX_CAMERA_H +#define SUPERTUX_CAMERA_H #include -#include "vector.h" -#include "game_object.h" -#include "serializable.h" #include +#include "defines.h" +#include "math/vector.h" +#include "special/game_object.h" +#include "video/drawing_context.h" +#include "serializable.h" + +using namespace SuperTux; + +namespace SuperTux { class LispReader; -class Player; -class Level; +} + +class Sector; class Camera : public GameObject, public Serializable { public: - Camera(Player* player = 0, Level* level = 0); + Camera(Sector* sector); 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 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); + /// reset camera postion + virtual void reset(const Vector& tuxpos); + + /** @deprecated@ */ + const Vector& get_translation() const; virtual void action(float elapsed_time); + virtual void draw(DrawingContext& ) + { + } + + void set_scrolling(int scroll_x, int scroll_y) + { + translation.x = scroll_x; + translation.y = scroll_y; + } + enum CameraMode { NORMAL, AUTOSCROLL, MANUAL @@ -75,8 +84,7 @@ private: Vector translation; - Player* player; - Level* level; + Sector* sector; // normal mode bool do_backscrolling; @@ -94,5 +102,5 @@ private: Vector current_dir; }; -#endif +#endif /*SUPERTUX_CAMERA_H*/