示例#1
0
        public static bool IntersectsWithTile(Sprites.Sprite collisionAble1, Level level, int tileX, int tileY, out int highY, out int lowY)
        {
            Engine.TileData data = level.GetTile(tileX, tileY);
            Tile            tile = level.TileSet[data.Data];
            Rectangle       rect = new Rectangle(0, 0, TileSet.TileSize, TileSet.TileSize), coll = collisionAble1.CollisionArea;

            rect.Offset(tileX * TileSet.TileSize, tileY * TileSet.TileSize);

            return(IntersectsWithTile(coll, collisionAble1.Mask, rect, tile.Mask, false, false, out highY, out lowY));
        }
示例#2
0
        public static SpriteMask FromTexture(Sprites.Sprite entity, Texture2D texture)
        {
            SpriteMask mask = new SpriteMask(entity);

            Color[] colors = new Color[mask.width * mask.height];
            texture.GetData <Color>(colors);

            for (int y = 0; y < mask.height; y++)
            {
                for (int x = 0; x < mask.width; x++)
                {
                    if (colors[x + y * mask.width] == Color.Black)
                    {
                        mask.mask[x + y * mask.width] = 1;
                    }
                }
            }

            return(mask);
        }
示例#3
0
 public void Follow(Sprites.Sprite sprite)
 {
     Position = sprite.Position + new Vector2(sprite.DrawingArea.Width, sprite.DrawingArea.Height) / 2 - new Vector2(resolution.SceneWidth, resolution.SceneHeight) / 2;
 }
示例#4
0
 protected SpriteMask(Sprites.Sprite sprite)
     : base(sprite.DrawingArea.Width, sprite.DrawingArea.Height)
 {
     this.sprite = sprite;
 }