X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcamera.h;h=bad7fdf2a442fc3596af617651670491a56528ba;hb=935c2f6a2a27248de63fba86b74a724675761487;hp=aaa8e1959de712aa42265d13126e7e035ed0ae54;hpb=b8c83bae1b0cd0367b6e3ac8c4c28e077eb1b594;p=supertux.git diff --git a/src/camera.h b/src/camera.h index aaa8e1959..bad7fdf2a 100644 --- a/src/camera.h +++ b/src/camera.h @@ -16,53 +16,67 @@ // 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__ -#include "vector.h" -#include "game_object.h" +#ifndef SUPERTUX_CAMERA_H +#define SUPERTUX_CAMERA_H + +#include +#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 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); + /// 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& context) + { + UNUSED_ARG(context); + } + + void set_scrolling(int scroll_x, int scroll_y) + { + translation.x = scroll_x; + translation.y = scroll_y; + } + 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 { @@ -71,11 +85,23 @@ private: Vector translation; - Player* player; - Level* level; - CameraMode mode; + Sector* sector; + + // normal mode + bool do_backscrolling; LeftRightScrollChange scrollchange; + + // autoscroll mode + class ScrollPoint { + public: + Vector position; + float speed; + }; + std::vector scrollpoints; + size_t auto_idx; + float auto_t; + Vector current_dir; }; -#endif +#endif /*SUPERTUX_CAMERA_H*/