コード例 #1
0
        /// <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)));
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
 public void RemoveSpriteFromGame(ISnapsSprite sprite)
 {
     removeSprites.Add(sprite);
 }
コード例 #4
0
 public void AddSpriteToGame(ISnapsSprite sprite)
 {
     sprite.SpriteSetup(graphicsCanvas);
     gameSprites.Add(sprite);
 }
コード例 #5
0
ファイル: SnapsEngine.cs プロジェクト: mzamp27/source
 /// <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);
 }
コード例 #6
0
ファイル: SnapsEngine.cs プロジェクト: mzamp27/source
 /// <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);
 }