From cd61e3e022084491758b7101eb0e755df99b68d4 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Thu, 21 Oct 2004 18:34:13 +0000 Subject: [PATCH] Bugfix: enemies below half the screen were not appearing and were causing problems at level begin. Dunno how did this bug only showed up after my changes, since it doesn't seem to be related. SVN-Revision: 2046 --- src/badguy.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/badguy.cpp b/src/badguy.cpp index e4f04ff43..8b152cd53 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -159,13 +159,12 @@ BadGuy::~BadGuy() void BadGuy::init() { - base.x = 0; - base.y = 0; + base.x = start_position.x; + base.y = start_position.y; base.width = 32; base.height = 32; mode = NORMAL; - dying = DYING_NOT; old_base = base; dir = LEFT; seen = false; @@ -177,8 +176,6 @@ BadGuy::init() specs = badguyspecs_manager->load(badguykind_to_string(kind)); - set_action("hide", "hide"); - // if we're in a solid tile at start correct that now if(Sector::current()) { if(kind != BAD_FLAME && kind != BAD_FISH && kind != BAD_FLAMEFISH && collision_object_map(base)) @@ -869,12 +866,12 @@ BadGuy::action(float elapsed_time) if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && start_position.x < scroll_x - base.width && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && - start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) + start_position.y < scroll_y + screen->h + Y_OFFSCREEN_DISTANCE) activate(RIGHT); else if (start_position.x > scroll_x + screen->w && start_position.x < scroll_x + screen->w + 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->h + Y_OFFSCREEN_DISTANCE) activate(LEFT); /* Special case for badguys on start of the level. * If in the future, it's possible to set Tux start pos, this case @@ -962,6 +959,9 @@ BadGuy::action(float elapsed_time) void BadGuy::draw(DrawingContext& context) { + if(!seen) + return; + if((dir == LEFT && action_left == "hide") || (dir == RIGHT && action_right == "hide")) return; @@ -1217,6 +1217,9 @@ BadGuy::collision(const MovingObject&, int) void BadGuy::collision(void *p_c_object, int c_object, CollisionType type) { + if(!seen) + return; + BadGuy* pbad_c = NULL; Bullet* pbullet_c = NULL; -- 2.11.0