3 // SuperTux - Unstable Tile
4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "unstable_tile.hpp"
24 #include "lisp/lisp.hpp"
25 #include "object_factory.hpp"
28 #include "resources.hpp"
29 #include "sprite/sprite.hpp"
30 #include "random_generator.hpp"
31 #include "object/bullet.hpp"
33 UnstableTile::UnstableTile(const lisp::Lisp& lisp)
34 : MovingSprite(lisp, LAYER_TILES, COLGROUP_STATIC), state(STATE_NORMAL)
36 sprite->set_action("normal");
40 UnstableTile::collision(GameObject& other, const CollisionHit& )
42 if(state == STATE_NORMAL) {
43 Player* player = dynamic_cast<Player*> (&other);
45 player->get_bbox().get_bottom() < get_bbox().get_top() + 7.0) {
46 state = STATE_CRUMBLING;
47 sprite->set_action("crumbling", 1);
54 UnstableTile::update(float elapsed_time)
62 if (sprite->animation_done()) {
63 state = STATE_DISINTEGRATING;
64 sprite->set_action("disintegrating", 1);
65 set_group(COLGROUP_DISABLED);
66 physic.enable_gravity(true);
70 case STATE_DISINTEGRATING:
71 movement = physic.get_movement(elapsed_time);
72 if (sprite->animation_done()) {
80 IMPLEMENT_FACTORY(UnstableTile, "unstable_tile");