Virtual machine for Firedancer, a Haxe based language for defining 2D shmup bullet-hell patterns.
haxelib install firedancer-vm
Prepare any firedancer.vm.ProgramPackage
instance created with Firedancer library.
If you have a serialized program (which is a JSON string), parse it by ProgramPackage.fromString()
.
Extend the classes below and override their methods:
firedancer.vm.Emitter
firedancer.vm.EventHandler
Assuming you set the compiler flag -D firedancer_use_actor_class
, create your actors by doing the below for each actor:
- Create a
firedancer.vm.ThreadList
instance. - Create a
firedancer.vm.PositionRef
instance that provides read access to the position of the actor at the end of the last frame. - Create a
firedancer.vm.Actor
instance passing the two above.
Without the compiler flag -D firedancer_use_actor_class
, the Actor
class is not available and you have to prepare any SoA or AoSoA style structures using the type banker.vector.WritableVector
for each property (see library banker).
Prepare another PositionRef
instance that indicates the position of the target to be aimed.
This may be either common in actors or specific to each actor.
At the beginning, at least one actor should be active and have any firedancer.vm.Program
instance.
Set any Program
instance (that you get from your ProgramPackage
instance) by ThreadList.set()
or Actor.setProgram()
.
Run firedancer.vm.Vm.run()
every frame for each actor, passing the below:
- The
programTable
that you get from yourProgramPackage
instance. - Instances of your classes extended from
EventHandler
andEmitter
. - The memory capacity in bytes, which you used when creating
ThreadList
instances. Typically it's common in all actors. - Your actor data (
#if firedancer_use_actor_class
, theActor
instance). - The
PositionRef
instance for the target position.
Then render the actors using any game framework or some kind of that.
Emits verbose log.
Specifies the underlying type of PositionRef
.
Example: -D firedancer_positionref_type=broker_BatchSprite
Valid values:
broker_BatchSprite
for usingbroker.draw.BatchSprite
heaps_BatchElement
for usingh2d.SpriteBatch.BatchElement
- Otherwise uses an anonymous structure
{ x: Float, y: Float }
Enables to use Actor
class instead of the default SoA (Structure of Arrays) style.
(Not yet tested)
Throws error if:
- infinite loop is detected in the
Vm
- unknown
Opcode
is detected in aProgram
Automatically set #if debug
.
- sinker v0.5.0 or compatible
- sneaker v0.11.0 or compatible
- banker v0.7.1 or compatible
- reckoner v0.2.0 or compatible
See also: FAL Haxe libraries