BulletML is a language designed to express bullet behaviour in a shoot'em up game (turn left, accelerate, spawn children, etc).
This repository contains a set of tools to manipulate BulletML in OCaml.
- a parser, to convert a representation (
xml-light) to an AST
- a printer
- a graphic interpreter using SDL
- a JS app using js_of_ocaml
- a test suite
An interpreter is available. Compile it using
make and run
./_obuild/bulletml_run/bulletml_run.asm examples/\[Original\]_btb_6.xml (or
any other pattern!).
Left click quits, right click reloads the pattern (if you think this is backwards, this is a great pull request to start contributing).
This particular example also displays the extensible nature of the interpreter:
bulletML has no language of colors, but there is a system of hooks. In that
case, this hook sets the state of bullets to
let hooks = [ "changecolor", fun _ -> Purple ]
And the drawing code uses the state to determine the correct sprite.
let draw_bullet window (bulleto, bulletp) b = let (pxf, pxy) = b.pos in let px = int_of_float pxf in let py = int_of_float pyf in let src = match b.state with | Blue -> bulleto | Purple -> bulletp in let dst_rect = Sdlvideo.rect ~x:px ~y:py ~w:0 ~h:0 in Sdlvideo.blit_surface ~src ~dst:window ~dst_rect ()
You can find it here.
How to build
Then, you can run
opam install ocp-build mparser xml-light sdl.
Finish the installation by running
make. Run test suite with
make check. Build JS app with
Bugs, contributing, etc
Contributors are welcome ! But please don't forget to follow the guidelines.
Feel free to report issues on github.
This can be redistributed under the BSD-2 clause license (see LICENSE).
(but you can totally buy me a beer if you think it's worth it)