Example #1
0
        public static bool Collide(this I2DGameObject gameObject1, I2DGameObject gameObject2)
        {
            if (gameObject1.Texture == null || gameObject2.Texture == null)
            {
                return(false);
            }
            Rectangle goodSprite1 = new Rectangle((int)gameObject1.Position.X,
                                                  (int)gameObject1.Position.Y, gameObject1.Texture.Width, gameObject1.Texture.Height);
            Rectangle goodSprite2 = new Rectangle((int)gameObject2.Position.X,
                                                  (int)gameObject2.Position.Y, gameObject2.Texture.Width, gameObject2.Texture.Height);

            return(goodSprite1.Intersects(goodSprite2));
        }
Example #2
0
 public static Rectangle GetRectangle(this I2DGameObject gameObject)
 {
     return(new Rectangle((int)gameObject.Position.X, (int)gameObject.Position.Y, gameObject.Texture.Width, gameObject.Texture.Height));
 }