Replaced Ref and RefCounter with std::shared_ptr<>
[supertux.git] / src / object / specialriser.cpp
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 "video/drawing_context.hpp"
18 #include "object/specialriser.hpp"
19 #include "supertux/sector.hpp"
20
21 SpecialRiser::SpecialRiser(Vector pos, std::shared_ptr<MovingObject> _child) :
22   offset(),
23   child(_child)
24 {
25   _child->set_pos(pos - Vector(0, 32));
26   offset = 0;
27 }
28
29 SpecialRiser::~SpecialRiser()
30 {
31 }
32
33 void
34 SpecialRiser::update(float elapsed_time)
35 {
36   offset += 50 * elapsed_time;
37   if(offset > 32) {
38     Sector::current()->add_object(child);
39     remove_me();
40   }
41 }
42
43 void
44 SpecialRiser::draw(DrawingContext& context)
45 {
46   context.push_transform();
47   context.set_translation(
48     context.get_translation() + Vector(0, -32 + offset));
49   child->draw(context);
50   context.pop_transform();
51 }
52
53 /* EOF */