From: Ricardo Cruz Date: Sat, 14 Aug 2004 11:50:58 +0000 (+0000) Subject: Changed Walking Tree direction change behavior. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3ec8b7992fc7fb96a2fb8c6a44d9022d4d07bb02;p=supertux.git Changed Walking Tree direction change behavior. SVN-Revision: 1776 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index 100931457..5b762bb21 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -818,29 +818,11 @@ BadGuy::action_wingling(double elapsed_time) void BadGuy::action_walkingtree(double elapsed_time) { - Player& tux = *Sector::current()->player; - Direction v_dir = physic.get_velocity_x() < 0 ? LEFT : RIGHT; - if (dying == DYING_NOT) check_horizontal_bump(); fall(); - if (mode == BGM_BIG && tux.dying == DYING_NOT) - { - if ((tux.base.x + tux.base.width/2 > base.x + base.width/2) && v_dir == LEFT) - { - dir = RIGHT; - physic.set_velocity_x(-physic.get_velocity_x()); - } - else if ((tux.base.x + tux.base.width/2 < base.x + base.width/2) && v_dir == RIGHT) - { - dir = LEFT; - physic.set_velocity_x(-physic.get_velocity_x()); - } - } - - physic.apply(elapsed_time, base.x, base.y, Sector::current()->gravity); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); @@ -1131,6 +1113,12 @@ BadGuy::squish(Player* player) { set_sprite(img_walkingtree_left_small, img_walkingtree_left_small); physic.set_velocity_x(physic.get_velocity_x() * 2.0f); + + /* Move to the player's direction */ + if(dir != Sector::current()->player->dir) + physic.set_velocity_x(-physic.get_velocity_x()); + dir = Sector::current()->player->dir; + // XXX magic number: 66 is BGM_BIG height player->bounce(this);