From 05a91678b95ecbc27c61ae23bf61abb432865f8a Mon Sep 17 00:00:00 2001 From: florianf Date: Sun, 28 Feb 2010 10:30:54 +0000 Subject: [PATCH] Haywire: Walk towards the player if possible. This is a simple version of the "follow the player" behavior proposed in the Milestone 2 design document. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6446 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/badguy/haywire.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/badguy/haywire.cpp b/src/badguy/haywire.cpp index ebcf3f12d..6dff5ccdf 100644 --- a/src/badguy/haywire.cpp +++ b/src/badguy/haywire.cpp @@ -130,6 +130,20 @@ Haywire::active_update(float elapsed_time) } } + if (is_exploding && !turn_around_timer.started()) { + Player *p = Sector::current()->get_nearest_player (this->get_pos ()); + + if (p) { + Direction player_dir = LEFT; + + if (p->get_pos ().x > this->get_pos ().x) + player_dir = RIGHT; + + if (player_dir != dir) + turn_around (); + } + } + WalkingBadguy::active_update(elapsed_time); } -- 2.11.0