Today I decided I'm going to stop working out features of Bullet Revolution and really dive into Bandle Games's BulletML implementation and use it to implement my own. Which will better integrate in XNA and my own project.
My current experience in handling XML is limited. I know how to parse them and how to write them, but to actually transform BulletML into interactive bullet patterns seems a little daunting to me.
Writing BulletML is simple enough, it's the parsing that's a but daunting to me.
BulletRef and ActionRef
With BulletRef and ActionRef you can use actions written somewhere in you BulletML document. The advantage of this is that you can re-use actions and bullet configurations of different places. I want this to work like that in the code too. If I have a bullet that is referenced a couple of times I want it to actually reference that one and single instance.
Repeat action
It's also possible to use the <repeat> node, this node allows you to repeat an Action an X number of times. These <repeat> nodes can only be find inside <action> nodes and contain a single <times> node and another <action> node.
That's all a <repeat> node does, so I don't think it should be a class but rather just an Int as a field inside the Action class.
There is a catch though, the bullets behave differently when you have <wait> node inside you repeating <action> and you <fire> a bullet it will shoot those at the interval set a <wait>. When you are using <fire> in <direction type="sequence">20</direction> without the <wait> node it will shoot <times>X</times> amount of bullet with their direction and 20 degrees steps all at once creating a circle. With the <wait> node it will shoot bullets one by one each turning 20 degrees creating a twirl effect. I think this will happen naturally with my design and thus shouldn't be a problem, but it something to look out for.
Bullets are Emitters
There is not really a clear "emitter shoots bullets" relation. In BulletML bullets can shoot other bullets so an Emitter class shooting Bullet's doesn't make sense since the bullets have the same functionality as the Emitter class had except it can travel. I've written a quick example on bullets shooting bullets which is visualised in the BulletML demo in different colours from "red > green > blue > pink (?)".
API
I do know how I want it to work from the outside. For starters, I want to use the Content Pipeline to immediately create a single "Pattern" or "Emitter" object I can call Update() and Draw() to update and draw all its bullets. So in a gun I would call something like "BulletML pattern = content.load<BulletML>("[1943]_rolling_fire")" to load the "[1943]_rolling_fire.xml" file.
I also want to call Shoot() on the BulletML object to run through the entire script and create all bullets needed by it which are then updated by the Update() method.
This is actually not all that different from Bandle's way of doing things. But there are a couple of things bugging me. One being the way you parse XML files, you need to call "parser.ParseXML(@"path/to/xml/file/bulletml.xml");" then in the sample provided by Bandle you need to create an instance of Mover, set the position and call "SetBullet(parser.tree);" from there I'm not really sure what happens. All I know is that after the pattern is done it created a new Mover object. With a couple of shooting enemies on screen with short patterns, it will create a whole lot of Movers.
P.S. I need better syntax highlighting on this blog. Can't use PasteBin forever, can I?
No comments:
Post a Comment