From 63585855b8937f6a492b13e2a8e62bf45b279084 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 25 May 2004 10:38:52 +0000 Subject: [PATCH] more tuning of badguy activation SVN-Revision: 1325 --- src/badguy.cpp | 13 ++++++++++--- src/world.cpp | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/badguy.cpp b/src/badguy.cpp index 67389d526..aa092ca84 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -215,9 +215,16 @@ BadGuy::init() --base.y; } - // just activate the badguy, since he might be on screen already. If not he - // gets deactivated anyway - activate(LEFT); + if(World::current()->camera) { + Vector scroll = World::current()->camera->get_translation(); + + if(start_position.x > scroll.x - X_OFFSCREEN_DISTANCE && + start_position.x < scroll.x + screen->w + X_OFFSCREEN_DISTANCE && + start_position.y > scroll.y - Y_OFFSCREEN_DISTANCE && + start_position.y < scroll.y + screen->h + Y_OFFSCREEN_DISTANCE) { + activate(LEFT); + } + } } void diff --git a/src/world.cpp b/src/world.cpp index 0c28cb001..70da9b4eb 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -43,6 +43,7 @@ Surface* img_distro[4]; World* World::current_ = 0; World::World(const std::string& filename, int level_nr) + : level(0), tux(0), background(0), camera(0) { // FIXME: Move this to action and draw and everywhere else where the // world calls child functions @@ -109,6 +110,8 @@ World::~World() } delete level; + + current_ = 0; } void -- 2.11.0