From: Florian Forster Date: Sun, 28 Feb 2010 10:30:54 +0000 (+0000) Subject: Haywire: Walk towards the player if possible. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=cc9f1cd9297aed8aa9c9f0d6ab314cd736c59a27;p=supertux.git 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. SVN-Revision: 6446 --- 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); }