sprite->set_action(dir == LEFT ? "large-left" : "large-right");
sound_manager->preload("sounds/mr_tree.ogg");
sound_manager->preload("sounds/mr_treehit.ogg");
+ recently_changed_direction = false;
}
void
void
MrTree::active_update(float elapsed_time)
{
+ recently_changed_direction = false;
if ((mystate == STATE_INVINCIBLE) && (invincible_timer.check())) {
mystate = STATE_NORMAL;
activate();
}
- if (might_fall())
+ if (might_fall() && !recently_changed_direction )
{
+ recently_changed_direction = true;
dir = (dir == LEFT ? RIGHT : LEFT);
activate();
}
if(hit.top || hit.bottom) {
physic.set_velocity_y(0);
} else {
+ if( recently_changed_direction ) return;
+ recently_changed_direction = true;
dir = dir == LEFT ? RIGHT : LEFT;
activate();
}
MrTree::collision_badguy(BadGuy& , const CollisionHit& hit)
{
if(hit.left || hit.right) {
+ if( recently_changed_direction ) return CONTINUE;
+ recently_changed_direction = true;
dir = dir == LEFT ? RIGHT : LEFT;
activate();
}
sound_manager->preload("sounds/iceblock_bump.wav");
sound_manager->preload("sounds/stomp.wav");
sound_manager->preload("sounds/kick.wav");
+ recently_changed_direction = false;
}
Snail::Snail(const Vector& pos, Direction d)
sound_manager->preload("sounds/iceblock_bump.wav");
sound_manager->preload("sounds/stomp.wav");
sound_manager->preload("sounds/kick.wav");
+ recently_changed_direction = false;
}
void
void
Snail::active_update(float elapsed_time)
{
+ recently_changed_direction = false;
switch (state) {
case STATE_NORMAL:
if (might_fall(601)) {
- dir = (dir == LEFT ? RIGHT : LEFT);
- sprite->set_action(dir == LEFT ? "left" : "right");
- physic.set_velocity_x(-physic.get_velocity_x());
+ if( recently_changed_direction ) break;
+ recently_changed_direction = true;
+ dir = (dir == LEFT ? RIGHT : LEFT);
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
}
break;
switch(state) {
case STATE_NORMAL:
+ if( recently_changed_direction ) break;
+ recently_changed_direction = true;
dir = dir == LEFT ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? "left" : "right");
physic.set_velocity_x(-physic.get_velocity_x());
brick->try_break();
}
#endif
-
+ if( recently_changed_direction ) break;
+ recently_changed_direction = true;
dir = (dir == LEFT) ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
switch(state) {
case STATE_NORMAL:
if(hit.left || hit.right) {
+ if( recently_changed_direction ) return CONTINUE;
+ recently_changed_direction = true;
dir = (dir == LEFT) ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? "left" : "right");
physic.set_velocity_x(-physic.get_velocity_x());