00001 // SuperTux - End Sequence: Tux walks right 00002 // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de> 00003 // 00004 // This program is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 #include "object/endsequence_walkleft.hpp" 00018 #include "object/player.hpp" 00019 #include "supertux/globals.hpp" 00020 #include "supertux/screen_manager.hpp" 00021 #include "supertux/sector.hpp" 00022 00023 EndSequenceWalkLeft::EndSequenceWalkLeft() : 00024 EndSequence(), 00025 last_x_pos(), 00026 endsequence_timer() 00027 { 00028 } 00029 00030 EndSequenceWalkLeft::~EndSequenceWalkLeft() 00031 { 00032 } 00033 00034 void 00035 EndSequenceWalkLeft::draw(DrawingContext& /*context*/) 00036 { 00037 } 00038 00039 void 00040 EndSequenceWalkLeft::starting() 00041 { 00042 EndSequence::starting(); 00043 last_x_pos = -1; 00044 endsequence_timer.start(7.3f * g_screen_manager->get_speed()); 00045 } 00046 00047 void 00048 EndSequenceWalkLeft::running(float elapsed_time) 00049 { 00050 EndSequence::running(elapsed_time); 00051 Player& tux = *Sector::current()->player; 00052 00053 if (tux_may_walk) { 00054 end_sequence_controller->press(Controller::LEFT); 00055 if (int(last_x_pos) == int(tux.get_pos().x)) { 00056 end_sequence_controller->press(Controller::JUMP); 00057 } 00058 } 00059 00060 last_x_pos = tux.get_pos().x; 00061 00062 if (endsequence_timer.check()) isdone = true; 00063 } 00064 00065 void 00066 EndSequenceWalkLeft::stopping() 00067 { 00068 EndSequence::stopping(); 00069 } 00070 00071 /* EOF */