/// <summary> /// Gives the distance in pixels between the center of /// this sprite and the center of the target sprite /// </summary> /// <param name="sprite">target sprite</param> /// <returns>distance in pixels</returns> public double DistanceFrom(ISnapsSprite sprite) { double dx = Math.Abs(this.CenterX - sprite.CenterX); double dy = Math.Abs(this.CenterY - sprite.CenterY); return(Math.Sqrt((dx * dx) + (dy * dy))); }
/// <summary> /// Text to see if a bounding box around this sprite /// intersects with a bounding box around another sprite /// </summary> /// <param name="sprite">sprite to test against</param> /// <returns>true if the bounding boxes intersect</returns> public bool IntersectsWith(ISnapsSprite sprite) { if (this.X > (sprite.X + sprite.Width)) { return(false); } if (this.Y > (sprite.Y + sprite.Height)) { return(false); } if (this.X + this.Width < sprite.X) { return(false); } if (this.Y + this.Height < sprite.Y) { return(false); } return(true); }
public void RemoveSpriteFromGame(ISnapsSprite sprite) { removeSprites.Add(sprite); }
public void AddSpriteToGame(ISnapsSprite sprite) { sprite.SpriteSetup(graphicsCanvas); gameSprites.Add(sprite); }
/// <summary> /// Remove the given sprite from the game engine. /// The sprite will no longer be drawn. If the sprite /// is not in the engine the method has no effect. /// </summary> /// <param name="sprite">sprite to be removed</param> public static void RemoveSpriteFromGame(ISnapsSprite sprite) { manager.RemoveSpriteFromGame(sprite); }
/// <summary> /// Add the given sprite to the game engine. The sprite will /// be drawn each time the game engine redraws. /// </summary> /// <param name="sprite">sprite to be added</param> public static void AddSpriteToGame(ISnapsSprite sprite) { manager.AddSpriteToGame(sprite); }