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)); }
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); }
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; }
protected SpriteMask(Sprites.Sprite sprite) : base(sprite.DrawingArea.Width, sprite.DrawingArea.Height) { this.sprite = sprite; }