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/specialriser.hpp" |
18 | |
19 | #include "supertux/sector.hpp" |
20 | #include "video/drawing_context.hpp" |
21 | |
22 | SpecialRiser::SpecialRiser(const Vector& pos, std::unique_ptr<MovingObject> child_) : |
23 | offset(0), |
24 | child(std::move(child_)) |
25 | { |
26 | child->set_pos(pos - Vector(0, 32)); |
27 | } |
28 | |
29 | void |
30 | SpecialRiser::update(float dt_sec) |
31 | { |
32 | offset += 50 * dt_sec; |
33 | if (offset > 32) { |
34 | Sector::get().add_object(std::move(child)); |
35 | remove_me(); |
36 | } |
37 | } |
38 | |
39 | void |
40 | SpecialRiser::draw(DrawingContext& context) |
41 | { |
42 | context.push_transform(); |
43 | context.set_translation( |
44 | context.get_translation() + Vector(0, -32 + offset)); |
45 | child->draw(context); |
46 | context.pop_transform(); |
47 | } |
48 | |
49 | /* EOF */ |
50 |