Skip to the content.

BulletMLLib

A C# library for parsing and executing BulletML XML files. Define complex bullet patterns declaratively in XML and execute them at runtime in your shmup (shoot-em-up) game.

Features

Requirements

Installation

Install via NuGet:

dotnet add package BulletMLLib

Or add to your .csproj:

<PackageReference Include="BulletMLLib" Version="5.*" />

Quick Example

// 1. Implement IBulletManager
public class MyBulletManager : IBulletManager
{
    public Random Rand { get; } = new Random();
    public Dictionary<string, FunctionDelegate> CallbackFunctions { get; } = new();
    public FunctionDelegate GameDifficulty { get; set; }

    public Vector2 PlayerPosition(IBullet bullet) => _playerPos;
    public IBullet CreateBullet() => new MyBullet(this);
    public IBullet CreateTopBullet() => new MyBullet(this);
    public void RemoveBullet(IBullet bullet) { /* mark inactive */ }
}

// 2. Inherit from Bullet
public class MyBullet : Bullet
{
    private Vector2 _position;
    public override float X { get => _position.X; set => _position.X = value; }
    public override float Y { get => _position.Y; set => _position.Y = value; }

    public MyBullet(IBulletManager manager) : base(manager) { }
    public override void PostUpdate() { /* check bounds, draw, etc. */ }
}

// 3. Load and run a pattern
var manager = new MyBulletManager();
var pattern = new BulletPattern(manager);
pattern.ParseXML("patterns/spiral.xml");

var topBullet = manager.CreateTopBullet();
topBullet.X = 200;
topBullet.Y = 50;
topBullet.InitTopNode(pattern.RootNode);

// 4. Each frame:
topBullet.Update();

Documentation

License

MIT