2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef HEADER_SUPERTUX_OBJECT_CAMERA_HPP
18 #define HEADER_SUPERTUX_OBJECT_CAMERA_HPP
22 #include "math/vector.hpp"
23 #include "supertux/game_object.hpp"
24 #include "supertux/script_interface.hpp"
25 #include "supertux/timer.hpp"
26 #include "util/reader_fwd.hpp"
33 class Camera : public GameObject,
34 public ScriptInterface
37 Camera(Sector* sector, std::string name = "");
40 /// parse camera mode from lisp file
41 void parse(const Reader& reader);
43 /// reset camera position
44 void reset(const Vector& tuxpos);
46 /** return camera position */
47 const Vector& get_translation() const;
49 virtual void update(float elapsed_time);
51 virtual void draw(DrawingContext& );
53 virtual void expose(HSQUIRRELVM vm, SQInteger table_idx);
54 virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
56 // shake camera in a direction 1 time
57 void shake(float speed, float x, float y);
59 void set_scrolling(int scroll_x, int scroll_y)
61 translation.x = scroll_x;
62 translation.y = scroll_y;
66 * scroll the upper left edge of the camera in scrolltime seconds
67 * to the position goal
69 void scroll_to(const Vector& goal, float scrolltime);
75 NORMAL, AUTOSCROLL, SCROLLTO, MANUAL
80 * get the coordinates of the point directly in the center of this camera
82 Vector get_center() const;
85 void update_scroll_normal(float elapsed_time);
86 void update_scroll_autoscroll(float elapsed_time);
87 void update_scroll_to(float elapsed_time);
88 void keep_in_bounds(Vector& vector);
93 * The camera basically provides lookahead on the left or right side
97 LOOKAHEAD_NONE, LOOKAHEAD_LEFT, LOOKAHEAD_RIGHT
106 LookaheadMode lookahead_mode;
108 Vector lookahead_pos;
110 Vector cached_translation;
113 std::auto_ptr<Path> autoscroll_path;
114 std::auto_ptr<PathWalker> autoscroll_walker;
128 CameraConfig *config;
131 Camera(const Camera&);
132 Camera& operator=(const Camera&);
135 #endif /*SUPERTUX_CAMERA_H*/