From: florianf Date: Fri, 5 Mar 2010 08:36:26 +0000 (+0000) Subject: badguy/walking_badguy.cpp: Turn the badguy around when his speed doesn't match the... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9eee33349b5823980fb4681c908aeed2f68fb9f5;p=supertux.git badguy/walking_badguy.cpp: Turn the badguy around when his speed doesn't match the direction he's facing. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6551 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/src/badguy/walking_badguy.cpp b/src/badguy/walking_badguy.cpp index 8ab7d35ed..203d5f727 100644 --- a/src/badguy/walking_badguy.cpp +++ b/src/badguy/walking_badguy.cpp @@ -137,6 +137,15 @@ WalkingBadguy::active_update(float elapsed_time, float dest_x_velocity) turn_around(); } } + + if ((dir == LEFT) && (physic.get_velocity_x () > 0.0)) { + dir = RIGHT; + set_action (walk_right_action, /* loops = */ -1); + } + else if ((dir == RIGHT) && (physic.get_velocity_x () < 0.0)) { + dir = LEFT; + set_action (walk_left_action, /* loops = */ -1); + } } void