From 80a6c35255a466eda1f1b9c1989110cd94461112 Mon Sep 17 00:00:00 2001 From: Daveo Date: Sat, 4 Aug 2001 21:06:19 +0000 Subject: [PATCH] --- source/fx/fxbubble.cpp | 1 + source/fx/fxfallingtile.cpp | 1 + source/thing/thing.cpp | 17 +++++++++++++++++ source/thing/thing.h | 3 ++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/source/fx/fxbubble.cpp b/source/fx/fxbubble.cpp index ff5c12ce3..ccdee331e 100644 --- a/source/fx/fxbubble.cpp +++ b/source/fx/fxbubble.cpp @@ -23,6 +23,7 @@ void CFXBubble::init(DVECTOR const &_Pos) Velocity.vy=-(getRndRange(4)+1); CurrentScaleX=CurrentScaleY=getRndRange(ONE/2)+(ONE/2); XIdx=getRnd()&15; + if (!isOnScreen(_Pos)) setToShutdown(); } /*****************************************************************************/ diff --git a/source/fx/fxfallingtile.cpp b/source/fx/fxfallingtile.cpp index cbf04b83c..0857d290f 100644 --- a/source/fx/fxfallingtile.cpp +++ b/source/fx/fxfallingtile.cpp @@ -38,6 +38,7 @@ sLevelHdr *LevelHdr=CLevel::getLevelHdr(); Velocity.vy=FallingTile_DefVY; Life=FallingTile_DefLife; CSoundMediator::playSfx(CSoundMediator::SFX_ANY_OBJECT_FALLING,false,true); + if (!isOnScreen(_Pos)) setToShutdown(); } /*****************************************************************************/ diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index f6cb16709..e6be749f8 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -1184,6 +1184,23 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); } +/****************************************************************************************/ +bool CThing::isOnScreen(DVECTOR Pos) +{ +// Check Is Onscreen +sBBox &ScrBBox=CThingManager::getRenderBBox(); +DVECTOR const &CamPos=CLevel::getCameraPos(); + + Pos.vx-=CamPos.vx; + Pos.vy-=CamPos.vy; + + if (Pos.vxScrBBox.XMax) return(false); + if (Pos.vyScrBBox.YMax) return(false); + return(true); +} + /****************************************************************************************/ void CThing::calcRenderPos(DVECTOR const &Pos,DVECTOR &renderPos) { diff --git a/source/thing/thing.h b/source/thing/thing.h index 52bffcf8e..db1791846 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -151,7 +151,8 @@ virtual void render(); u8 isSetToShutdown() {return( m_isShuttingDown);} virtual int dontKillDuringLevelRespawn() {return false;} void calcRenderPos(DVECTOR const &Pos,DVECTOR &renderPos); - + bool isOnScreen(DVECTOR Pos); + // Linkage void addChild(CThing *Child); void removeChild(CThing *Child);