The new behavior is as follows: If the sprite has a "dissolve" action, it is
triggered on contact. If the "dissolve" animation ends, or if the sprite
doesn't have a "dissolve" action, the "fall-down" action is triggered. If that
animation is done, or if the sprite doesn't have a "fall-down" action, the
object is removed.
Possible future improvements:
- Make the tile non-solid at the end of "dissolve", rather than at the
beginning of "fall-down". This way falling only sprites would still be solid.
For this to be of use the collision detection needs to be improved, though.
- Also, remove the object after is has hit a solid object or has fallen out of
the screen. The "remove at end of animation" behavior is more of a dirty
hack.
SVN-Revision: 6479
(fps 8)
(images
"castleblock-0.png"
(fps 8)
(images
"castleblock-0.png"
- (action
- (name "disintegrating")
- (fps 1)
- (images
- "castleblock-3.png"
- )
- )
+; (action
+; (name "fall-down")
+; (fps 1)
+; (images
+; "castleblock-3.png"
+; )
+; )
(fps 8)
(images
"snow-0.png"
(fps 8)
(images
"snow-0.png"
- (action
- (name "disintegrating")
- (fps 1)
- (images
- "snow-9.png"
- )
- )
+; (action
+; (name "fall-down")
+; (fps 1)
+; (images
+; "snow-9.png"
+; )
+; )
(fps 20)
(images
"crumbling-0.png"
(fps 20)
(images
"crumbling-0.png"
- (action
- (name "disintegrating")
- (fps 1)
- (images
- "normal.png"
- )
- )
+; (action
+; (name "fall-down")
+; (fps 1)
+; (images
+; "normal.png"
+; )
+; )
// SuperTux - Unstable Tile
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
// SuperTux - Unstable Tile
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+// Copyright (C) 2010 Florian Forster <supertux at octo.it>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Player* player = dynamic_cast<Player*> (&other);
if(player != NULL &&
player->get_bbox().get_bottom() < get_bbox().get_top() + SHIFT_DELTA) {
Player* player = dynamic_cast<Player*> (&other);
if(player != NULL &&
player->get_bbox().get_bottom() < get_bbox().get_top() + SHIFT_DELTA) {
}
if (dynamic_cast<Explosion*> (&other)) {
}
if (dynamic_cast<Explosion*> (&other)) {
-void
-UnstableTile::startCrumbling()
+void UnstableTile::dissolve (void)
- if (state != STATE_NORMAL) return;
- state = STATE_CRUMBLING;
- sprite->set_action("crumbling", 1);
+ if (state != STATE_NORMAL)
+ return;
+
+ if (sprite->has_action ("dissolve")) {
+ state = STATE_DISSOLVE;
+ this->set_action ("dissolve", /* loops = */ 1);
+ }
+ else {
+ fall_down ();
+ }
+}
+
+void UnstableTile::fall_down (void)
+{
+ if ((state != STATE_NORMAL) && (state != STATE_DISSOLVE))
+ return;
+
+ if (sprite->has_action ("fall-down")) {
+ state = STATE_FALL;
+ this->set_action ("fall-down", /* loops = */ 1);
+ set_group (COLGROUP_DISABLED);
+ physic.enable_gravity (true);
+ }
+ else {
+ remove_me ();
+ }
}
void
UnstableTile::update(float elapsed_time)
{
}
void
UnstableTile::update(float elapsed_time)
{
case STATE_NORMAL:
break;
case STATE_NORMAL:
break;
- case STATE_CRUMBLING:
- if (sprite->animation_done()) {
- state = STATE_DISINTEGRATING;
- sprite->set_action("disintegrating", 1);
- set_group(COLGROUP_DISABLED);
- physic.enable_gravity(true);
- }
+ case STATE_DISSOLVE:
+ if (sprite->animation_done())
+ fall_down ();
- case STATE_DISINTEGRATING:
- movement = physic.get_movement(elapsed_time);
- if (sprite->animation_done()) {
- remove_me();
- return;
- }
+ case STATE_FALL:
+ if (sprite->animation_done())
+ remove_me ();
+ else
+ movement = physic.get_movement (elapsed_time);
// SuperTux - Unstable Tile
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
// SuperTux - Unstable Tile
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+// Copyright (C) 2010 Florian Forster <supertux at octo.it>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
- STATE_NORMAL, /**< default state */
- STATE_CRUMBLING, /**< crumbling, still solid */
- STATE_DISINTEGRATING /**< disintegrating, no longer solid */
+ STATE_NORMAL, /**< default state */
+ STATE_DISSOLVE, /**< crumbling, still solid */
+ STATE_FALL /**< disintegrating, no longer solid */
};
void startCrumbling();
private:
};
void startCrumbling();
private:
+ void dissolve (void);
+ void fall_down (void);
+
Physic physic;
State state;
};
Physic physic;
State state;
};
return action->surfaces[frame_];
}
return action->surfaces[frame_];
}
+ bool has_action (const std::string& name)
+ {
+ return (data.get_action(name) != NULL);
+ }
+