From 567f43b64a62a3f2b4874287c02eba1560e6e436 Mon Sep 17 00:00:00 2001 From: Wolfgang Becker Date: Wed, 8 Nov 2006 18:09:23 +0000 Subject: [PATCH] Update magic blocks only if center is on screen. SVN-Revision: 4437 --- src/object/magicblock.cpp | 8 ++++---- src/object/player.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/object/magicblock.cpp b/src/object/magicblock.cpp index b09e7cbb7..31fcf5ef1 100644 --- a/src/object/magicblock.cpp +++ b/src/object/magicblock.cpp @@ -73,14 +73,14 @@ 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. + //Check if center of 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)) { + if((center.x > screen_right ) || ( center.y > screen_bottom) || + ( center.x < screen_left) || ( center.y < screen_top)) { switch_delay = SWITCH_DELAY; return; } diff --git a/src/object/player.cpp b/src/object/player.cpp index 6e9ee7c70..ad2e91e3e 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -805,7 +805,7 @@ Player::draw(DrawingContext& context) return; // if Tux is above camera, draw little "air arrow" to show where he is x-wise - if (Sector::current() && Sector::current()->camera && (get_bbox().p2.y + 16 < Sector::current()->camera->get_translation().y)) { + if (Sector::current() && Sector::current()->camera && (get_bbox().p2.y - 16 < Sector::current()->camera->get_translation().y)) { float px = get_pos().x + (get_bbox().p2.x - get_bbox().p1.x - airarrow.get()->get_width()) / 2; float py = Sector::current()->camera->get_translation().y; py += std::min(((py - (get_bbox().p2.y + 16)) / 4), 16.0f); -- 2.11.0