00001 // SuperTux 00002 // Copyright (C) 2006 Matthias Braun <matze@braunis.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 "badguy/yeti_stalactite.hpp" 00018 00019 #include "sprite/sprite.hpp" 00020 #include "supertux/object_factory.hpp" 00021 00022 static const float YT_SHAKE_TIME = .8f; 00023 00024 YetiStalactite::YetiStalactite(const Reader& lisp) 00025 : Stalactite(lisp) 00026 { 00027 } 00028 00029 YetiStalactite::~YetiStalactite() 00030 { 00031 } 00032 00033 void 00034 YetiStalactite::start_shaking() 00035 { 00036 timer.start(YT_SHAKE_TIME); 00037 state = STALACTITE_SHAKING; 00038 if(((int)get_pos().x / 32) % 2 == 0) { 00039 physic.set_velocity_y(100); 00040 } 00041 } 00042 00043 bool 00044 YetiStalactite::is_hanging() 00045 { 00046 return state == STALACTITE_HANGING; 00047 } 00048 00049 void 00050 YetiStalactite::active_update(float elapsed_time) 00051 { 00052 if(state == STALACTITE_HANGING) 00053 return; 00054 00055 Stalactite::active_update(elapsed_time); 00056 } 00057 00058 void 00059 YetiStalactite::update(float elapsed_time) 00060 { 00061 // Respawn instead of removing once squished 00062 if(get_state() == STATE_SQUISHED && check_state_timer()) { 00063 set_state(STATE_ACTIVE); 00064 state = STALACTITE_HANGING; 00065 // Hopefully we shouldn't come into contact with anything... 00066 sprite->set_action("normal"); 00067 set_pos(start_position); 00068 set_colgroup_active(COLGROUP_TOUCHABLE); 00069 } 00070 00071 // Call back to badguy to do normal stuff 00072 BadGuy::update(elapsed_time); 00073 } 00074 00075 /* EOF */