X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy.cpp;h=5e496ec4ae59b8db779e927183650115649e007f;hb=e68610f027ad6f35025d9aca87202ceb4501e97e;hp=8b152cd53178c3030bdbca39aee6363a745efa18;hpb=cd61e3e022084491758b7101eb0e755df99b68d4;p=supertux.git diff --git a/src/badguy.cpp b/src/badguy.cpp index 8b152cd53..5e496ec4a 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -210,6 +210,9 @@ BadGuy::activate(Direction activation_dir) frozen_timer.init(true); timer.init(true); + dying = DYING_NOT; + seen = true; + dir = activation_dir; float dirsign = activation_dir == LEFT ? -1 : 1; @@ -257,11 +260,6 @@ BadGuy::activate(Direction activation_dir) base.width = 66; base.height = 66; } - - base.x = start_position.x; - base.y = start_position.y; - old_base = base; - seen = true; } Surface* @@ -873,6 +871,18 @@ BadGuy::action(float elapsed_time) start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && start_position.y < scroll_y + screen->h + Y_OFFSCREEN_DISTANCE) activate(LEFT); + else if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && + start_position.x < scroll_x + screen->w + X_OFFSCREEN_DISTANCE && + ((start_position.y > scroll_y + screen->h && + start_position.y < scroll_y + screen->h + Y_OFFSCREEN_DISTANCE) || + (start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && + start_position.y < scroll_y))) + { + if(start_position.x < scroll_x - screen->w/2) + activate(RIGHT); + else + 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 * should contemplate that. */ @@ -895,7 +905,7 @@ BadGuy::action(float elapsed_time) if(!seen) return; - + switch (kind) { case BAD_MRICEBLOCK: @@ -1217,9 +1227,6 @@ 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;