From 262e632af0d00ddc8bd4b5b2fb9777624c2425c9 Mon Sep 17 00:00:00 2001 From: mathnerd314 Date: Thu, 21 Jan 2010 00:23:58 +0000 Subject: [PATCH] Badguy activation/deactivation (Matt's patch from bug 540) git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6268 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/badguy/badguy.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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) { -- 2.11.0