Exemple #1
0
        public static bool IsSpriteInView(Loc2D camStart, Loc2D camEnd, ISprite sprite)
        {
            if (sprite == null)
            {
                return(false);
            }
            Loc2D spriteStart = sprite.GetStart();
            Loc2D spriteEnd   = sprite.GetEnd();

            if (spriteStart == spriteEnd)
            {
                return(true);
            }

            //check to see if the sprite's left is to the right of the screen's right side
            if (spriteStart.X > camEnd.X)
            {
                return(false);
            }

            //check to see if the sprite's right is to the left of the screen's left side
            if (spriteEnd.X < camStart.X)
            {
                return(false);
            }

            //check to see if the sprite's top is to the bottom of the screen's bottom side
            if (spriteStart.Y > camEnd.Y)
            {
                return(false);
            }

            //check to see if the sprite's bottom is to the top of the screen's top side
            if (spriteEnd.Y < camStart.Y)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public static bool IsSpriteInView(Loc2D camStart, Loc2D camEnd, ISprite sprite)
        {
            if (sprite == null) return false;
            Loc2D spriteStart = sprite.GetStart();
            Loc2D spriteEnd = sprite.GetEnd();

            if (spriteStart == spriteEnd)
                return true;

            //check to see if the sprite's left is to the right of the screen's right side
            if (spriteStart.X > camEnd.X)
                return false;

            //check to see if the sprite's right is to the left of the screen's left side
            if (spriteEnd.X < camStart.X)
                return false;

            //check to see if the sprite's top is to the bottom of the screen's bottom side
            if (spriteStart.Y > camEnd.Y)
                return false;

            //check to see if the sprite's bottom is to the top of the screen's top side
            if (spriteEnd.Y < camStart.Y)
                return false;

            return true;
        }