Skip to content

tombiagioni/bulletml

 
 

Repository files navigation

λx. colored nonsense Build Status Coverage Status

BulletML is a language designed to express bullet behaviour in a shoot'em up game (turn left, accelerate, spawn children, etc).

A pattern Another pattern Yet another one

This repository contains a set of tools to manipulate BulletML in OCaml.

It contains:

  • 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

Interpreter

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 Purple:

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 ()

API documentation

You can find it here.

How to build

Prereqs

Install OCaml, opam, and libsdl-image1.2-dev from your distribution.

Then, you can run opam install ocp-build mparser xml-light sdl.

Finish the installation by running ocp-build -init.

After

make. Run test suite with make check. Build JS app with make js.

Bugs, contributing, etc

Contributors are welcome ! But please don't forget to follow the guidelines.

Feel free to report issues on github.

Legal stuff

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)

Links

About

Tools to manipulate and interpret shmup patterns

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • OCaml 91.1%
  • Makefile 2.4%
  • Shell 2.1%
  • Standard ML 2.1%
  • HTML 2.0%
  • Max 0.3%