From bc1e57c4ec82acc095df9a16f70b17496033ff18 Mon Sep 17 00:00:00 2001 From: Wolfgang Becker Date: Sun, 17 Sep 2006 16:53:42 +0000 Subject: [PATCH] Don't update magic blocks that are not on the screen, because it's dark there. SVN-Revision: 4240 --- src/object/magicblock.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/object/magicblock.cpp b/src/object/magicblock.cpp index 0e9968724..352bf9894 100644 --- a/src/object/magicblock.cpp +++ b/src/object/magicblock.cpp @@ -26,10 +26,12 @@ #include #include +#include "object/camera.hpp" #include "magicblock.hpp" #include "object_factory.hpp" #include "sprite/sprite_manager.hpp" #include "sector.hpp" +#include "main.hpp" namespace { const float MIN_INTENSITY = 0.8; @@ -63,6 +65,17 @@ MagicBlock::MagicBlock(const lisp::Lisp& lisp) void MagicBlock::update(float elapsed_time) { + //Check if this block is on screen. + //Don't update if not because there is no light off screen. + float screen_left = Sector::current()->camera->get_translation().x; + float screen_top = Sector::current()->camera->get_translation().y; + float screen_right = screen_left+ SCREEN_WIDTH; + float screen_bottom = screen_top + SCREEN_HEIGHT; + if((get_bbox().p1.x > screen_right ) || ( get_bbox().p1.y > screen_bottom) || + ( get_bbox().p2.x < screen_left) || ( get_bbox().p2.y < screen_top)) { + return; + } + bool lighting_ok = (light.red >= trigger_red && light.green >= trigger_green && light.blue >= trigger_blue); -- 2.11.0