1// SuperTux
2// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3//
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.
8//
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.
13//
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/>.
16
17#include "object/camera.hpp"
18
19#include "scripting/camera.hpp"
20#include "supertux/sector.hpp"
21#include "util/dynamic_scoped_ref.hpp"
22#include "util/log.hpp"
23
24namespace scripting {
25
26void
27Camera::reload_config()
28{
29 SCRIPT_GUARD_VOID;
30 BIND_SECTOR(::Sector::get());
31 object.reload_config();
32}
33
34void
35Camera::shake(float speed, float x, float y)
36{
37 SCRIPT_GUARD_VOID;
38 BIND_SECTOR(::Sector::get());
39 object.shake(speed, x, y);
40}
41
42void
43Camera::set_pos(float x, float y)
44{
45 SCRIPT_GUARD_VOID;
46 BIND_SECTOR(::Sector::get());
47 object.scroll_to(Vector(x, y), 0.0f);
48}
49
50void
51Camera::set_mode(const std::string& mode)
52{
53 SCRIPT_GUARD_VOID;
54 BIND_SECTOR(::Sector::get());
55
56 if (mode == "normal") {
57 object.set_mode(::Camera::Mode::NORMAL);
58 } else if (mode == "manual") {
59 object.set_mode(::Camera::Mode::MANUAL);
60 } else {
61 log_fatal << "Camera mode '" << mode << "' unknown.";
62 }
63}
64
65void
66Camera::scroll_to(float x, float y, float scrolltime)
67{
68 SCRIPT_GUARD_VOID;
69 BIND_SECTOR(::Sector::get());
70 object.scroll_to(Vector(x, y), scrolltime);
71}
72
73} // namespace scripting
74
75/* EOF */
76