| 1 | // SuperTux - End Sequence |
|---|---|
| 2 | // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.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/endsequence.hpp" |
| 18 | |
| 19 | #include "object/player.hpp" |
| 20 | #include "supertux/sector.hpp" |
| 21 | |
| 22 | EndSequence::EndSequence() : |
| 23 | isrunning(false), |
| 24 | isdone(false), |
| 25 | tux_may_walk(true), |
| 26 | end_sequence_controller() |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | EndSequence::~EndSequence() |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | void |
| 35 | EndSequence::update(float dt_sec) |
| 36 | { |
| 37 | if (!isrunning) return; |
| 38 | running(dt_sec); |
| 39 | } |
| 40 | |
| 41 | void |
| 42 | EndSequence::draw(DrawingContext& /*context*/) |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | void |
| 47 | EndSequence::start() |
| 48 | { |
| 49 | if (isrunning) return; |
| 50 | isrunning = true; |
| 51 | isdone = false; |
| 52 | |
| 53 | Player& tux = Sector::get().get_player(); |
| 54 | end_sequence_controller.reset(new CodeController()); |
| 55 | tux.set_controller(end_sequence_controller.get()); |
| 56 | tux.set_speedlimit(230); //MAX_WALK_XM |
| 57 | |
| 58 | starting(); |
| 59 | } |
| 60 | |
| 61 | void |
| 62 | EndSequence::stop_tux() |
| 63 | { |
| 64 | tux_may_walk = false; |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | EndSequence::stop() |
| 69 | { |
| 70 | if (!isrunning) return; |
| 71 | isrunning = false; |
| 72 | isdone = true; |
| 73 | stopping(); |
| 74 | } |
| 75 | |
| 76 | bool |
| 77 | EndSequence::is_tux_stopped() const |
| 78 | { |
| 79 | return !tux_may_walk; |
| 80 | } |
| 81 | |
| 82 | bool |
| 83 | EndSequence::is_done() const |
| 84 | { |
| 85 | return isdone; |
| 86 | } |
| 87 | |
| 88 | void |
| 89 | EndSequence::starting() |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | void |
| 94 | EndSequence::running(float /*dt_sec*/) |
| 95 | { |
| 96 | end_sequence_controller->update(); |
| 97 | } |
| 98 | |
| 99 | void |
| 100 | EndSequence::stopping() |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | /* EOF */ |
| 105 |