00001 #ifndef ActorCollision_H 00002 #define ActorCollision_H 00003 00004 #include "Actor.h" 00005 #include "GameConstantsAndTypes.h" 00006 #include "ScreenDimensions.h" 00007 00008 00009 inline float GetOffScreenLeft( Actor* pActor ) { return SCREEN_LEFT - pActor->GetZoomedWidth()/2; } 00010 inline float GetOffScreenRight( Actor* pActor ) { return SCREEN_RIGHT + pActor->GetZoomedWidth()/2; } 00011 inline float GetOffScreenTop( Actor* pActor ) { return SCREEN_TOP - pActor->GetZoomedHeight()/2; } 00012 inline float GetOffScreenBottom(Actor* pActor ) { return SCREEN_BOTTOM+ pActor->GetZoomedHeight()/2; } 00013 00014 inline bool IsOffScreenLeft( Actor* pActor ) { return pActor->GetX() < GetOffScreenLeft(pActor); } 00015 inline bool IsOffScreenRight( Actor* pActor ) { return pActor->GetX() > GetOffScreenRight(pActor); } 00016 inline bool IsOffScreenTop( Actor* pActor ) { return pActor->GetY() < GetOffScreenTop(pActor); } 00017 inline bool IsOffScreenBottom(Actor* pActor ) { return pActor->GetY() > GetOffScreenBottom(pActor); } 00018 inline bool IsOffScreen( Actor* pActor ) { return IsOffScreenLeft(pActor) || IsOffScreenRight(pActor) || IsOffScreenTop(pActor) || IsOffScreenBottom(pActor); } 00019 00020 // guard rail is the area that keeps particles from going off screen 00021 inline float GetGuardRailLeft( Actor* pActor ) { return SCREEN_LEFT + pActor->GetZoomedWidth()/2; } 00022 inline float GetGuardRailRight( Actor* pActor ) { return SCREEN_RIGHT - pActor->GetZoomedWidth()/2; } 00023 inline float GetGuardRailTop( Actor* pActor ) { return SCREEN_TOP + pActor->GetZoomedHeight()/2; } 00024 inline float GetGuardRailBottom(Actor* pActor ) { return SCREEN_BOTTOM- pActor->GetZoomedHeight()/2; } 00025 00026 inline bool HitGuardRailLeft( Actor* pActor ) { return pActor->GetX() < GetGuardRailLeft(pActor); } 00027 inline bool HitGuardRailRight( Actor* pActor ) { return pActor->GetX() > GetGuardRailRight(pActor); } 00028 inline bool HitGuardRailTop( Actor* pActor ) { return pActor->GetY() < GetGuardRailTop(pActor); } 00029 inline bool HitGuardRailBottom(Actor* pActor ) { return pActor->GetY() > GetGuardRailBottom(pActor); } 00030 00031 00032 #endif 00033 00034 /* 00035 * (c) 2001-2002 Chris Danford 00036 * All rights reserved. 00037 * 00038 * Permission is hereby granted, free of charge, to any person obtaining a 00039 * copy of this software and associated documentation files (the 00040 * "Software"), to deal in the Software without restriction, including 00041 * without limitation the rights to use, copy, modify, merge, publish, 00042 * distribute, and/or sell copies of the Software, and to permit persons to 00043 * whom the Software is furnished to do so, provided that the above 00044 * copyright notice(s) and this permission notice appear in all copies of 00045 * the Software and that both the above copyright notice(s) and this 00046 * permission notice appear in supporting documentation. 00047 * 00048 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00049 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00050 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00051 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00052 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00053 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00054 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00055 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00056 * PERFORMANCE OF THIS SOFTWARE. 00057 */