Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[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, MovingObject* _child)
22   : child(_child)
23 {
24   _child->set_pos(pos - Vector(0, 32));
25   offset = 0;
26 }
27
28 SpecialRiser::~SpecialRiser()
29 {
30 }
31
32 void
33 SpecialRiser::update(float elapsed_time)
34 {
35   offset += 50 * elapsed_time;
36   if(offset > 32) {
37     Sector::current()->add_object(child);
38     remove_me();
39   }
40 }
41
42 void
43 SpecialRiser::draw(DrawingContext& context)
44 {
45   context.push_transform();
46   context.set_translation(
47     context.get_translation() + Vector(0, -32 + offset));
48   child->draw(context);
49   context.pop_transform();
50 }
51
52 /* EOF */