From: Wolfgang Becker Date: Tue, 30 May 2006 17:38:23 +0000 (+0000) Subject: Activate badguys over or under current visible screen. Mind your head. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=fa5dbbdb7de39ec9196bdb62f582ebdfbb9b3228;p=supertux.git Activate badguys over or under current visible screen. Mind your head. SVN-Revision: 3612 --- diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 6d2632f55..c2b002d88 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -302,13 +302,15 @@ BadGuy::try_activate() /* Activate badguys if they're just around the screen to avoid * the effect of having badguys suddenly popping up from nowhere. */ - if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && + //Badguy left of screen + if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && start_position.x < scroll_x - bbox.get_width() && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) { dir = RIGHT; set_state(STATE_ACTIVE); activate(); + //Badguy right of screen } else if (start_position.x > scroll_x + SCREEN_WIDTH && start_position.x < scroll_x + SCREEN_WIDTH + X_OFFSCREEN_DISTANCE && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && @@ -316,6 +318,16 @@ BadGuy::try_activate() dir = LEFT; set_state(STATE_ACTIVE); activate(); + //Badguy over or under screen + } else if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && + start_position.x < scroll_x + X_OFFSCREEN_DISTANCE && + ((start_position.y > scroll_y + SCREEN_HEIGHT && + start_position.y < scroll_y + SCREEN_HEIGHT + Y_OFFSCREEN_DISTANCE) || + (start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && + start_position.y < scroll_y - bbox.get_height() ))) { + dir = start_position.x < scroll_x ? RIGHT : LEFT; + set_state(STATE_ACTIVE); + activate(); } else if(state == STATE_INIT && start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE