From: Wolfgang Becker Date: Fri, 12 Jan 2007 20:10:15 +0000 (+0000) Subject: offscreen.patch by Klaus Denker: correct some calculations X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=339968d0eb222f5cad1397580631ab44acf40b10;p=supertux.git offscreen.patch by Klaus Denker: correct some calculations SVN-Revision: 4554 --- diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index c9d42cd8f..56fe165b5 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -391,9 +391,9 @@ BadGuy::is_offscreen() float scroll_y = Sector::current()->camera->get_translation().y; if(bbox.p2.x < scroll_x - X_OFFSCREEN_DISTANCE - || bbox.p1.x > scroll_x + X_OFFSCREEN_DISTANCE + || bbox.p1.x > scroll_x + X_OFFSCREEN_DISTANCE + SCREEN_WIDTH || bbox.p2.y < scroll_y - Y_OFFSCREEN_DISTANCE - || bbox.p1.y > scroll_y + Y_OFFSCREEN_DISTANCE) + || bbox.p1.y > scroll_y + Y_OFFSCREEN_DISTANCE + SCREEN_HEIGHT) return true; return false; @@ -412,7 +412,7 @@ BadGuy::try_activate() 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) { + start_position.y < scroll_y + SCREEN_HEIGHT + Y_OFFSCREEN_DISTANCE) { if (start_dir != AUTO) dir = start_dir; else dir = RIGHT; set_state(STATE_ACTIVE); activate(); @@ -420,13 +420,13 @@ BadGuy::try_activate() } 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 && - start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) { + start_position.y < scroll_y + SCREEN_HEIGHT + Y_OFFSCREEN_DISTANCE) { if (start_dir != AUTO) dir = start_dir; else 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.x < scroll_x + SCREEN_WIDTH + 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 && @@ -445,9 +445,9 @@ BadGuy::try_activate() activate(); } else if(state == STATE_INIT && start_position.x > scroll_x - X_OFFSCREEN_DISTANCE - && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE + && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE + SCREEN_WIDTH && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE - && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) { + && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE + SCREEN_HEIGHT ) { if (start_dir != AUTO) { dir = start_dir; } else {