From: Mathnerd314 Date: Thu, 21 Jan 2010 00:23:58 +0000 (+0000) Subject: Badguy activation/deactivation (Matt's patch from bug 540) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1e55a294c4a3141bc7c1e94c890b8a4ba7117d23;p=supertux.git Badguy activation/deactivation (Matt's patch from bug 540) SVN-Revision: 6268 --- diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index b30e1d3c1..e794ce4f4 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -433,7 +433,9 @@ BadGuy::is_offscreen() Player* player = get_nearest_player(); if (!player) return false; Vector dist = player->get_bbox().get_middle() - get_bbox().get_middle(); - if ((dist.x <= X_OFFSCREEN_DISTANCE+32) && (dist.y <= Y_OFFSCREEN_DISTANCE+32)) { + // In SuperTux 0.1.x, Badguys were activated when Tux<->Badguy center distance was approx. <= ~668px + // This doesn't work for wide-screen monitors which give us a virt. res. of approx. 1066px x 600px + if ((fabsf(dist.x) <= X_OFFSCREEN_DISTANCE) && (fabsf(dist.y) <= Y_OFFSCREEN_DISTANCE)) { return false; } return true; @@ -442,12 +444,11 @@ BadGuy::is_offscreen() void BadGuy::try_activate() { - // In SuperTux 0.1.x, Badguys were activated when Tux<->Badguy center distance was approx. <= ~668px - // This doesn't work for wide-screen monitors which give us a virt. res. of approx. 1066px x 600px + // Don't activate if player is dying Player* player = get_nearest_player(); if (!player) return; - Vector dist = player->get_bbox().get_middle() - get_bbox().get_middle(); - if ((fabsf(dist.x) <= X_OFFSCREEN_DISTANCE) && (fabsf(dist.y) <= Y_OFFSCREEN_DISTANCE)) { + + if (!is_offscreen()) { set_state(STATE_ACTIVE); if (!is_initialized) {