HTML 5 canvas implementation of Mario written in Ocaml
545
stars
115
commits
OCaml
primary language
Apr 5, 2026
updated
MariOCaml is an HTML 5 canvas web-browser implementation of the Super Mario Bros platformer written exclusively in Ocaml.

MariOcaml is an OCaml implementation of Super Mario Bros. The game includes several basic enemies, blocks, and items, with particle support. The underlying system follows a director model, with the director maintaining state based on game objects and tiles, including Mario, items, and obstacles. The implementation of enemies and items is designed to be easily extensible. Furthermore, MariOcaml supports a game-over and game-win states, as well as score and coin counts, emulating several of the core mechanics of Mario.
The design follows a clean, modular, and extensible system to ensure that more features can easily be added. Levels are procedurally generated (pseudo-randomly), algorithmically creating an environment of textures and objects that are interactable. The procedural generation generally generates a playable map, but due to the nature of random generation, maps may not be the most aesthetically appealing. Additionally, the game is interactive and graphical using js_of_ocaml, which enables cross-compiliation of Ocaml to javascript, allowing MariOcaml to be run in any modern web browser.
The underlying procedural generation utilizes a grid system to generate objects, taking account parameters such as proximity and location. During game-play, the director maintains the game state, including the location and status of both items, enemies, and the character.
If you don't have opam installed, see the official instructions.
Create a local opam switch in the project root and reload the environment. Creating the switch will prompt you to install project dependencies.
opam switch create .
eval $(opam env)
Once all dependencies are installed, run:
make all
to compile the binaries to the _build folder and run the js_of_ocaml cross-compiler.
http://localhost:8000 in a web-browser to run the game!Pull requests fixing bugs, adding functionality, or improving organization are welcome!
MariOCaml was originally conceived for Cornell University's Fall 2015 CS3110 final project.
OCaml
91.8%
CSS
3.9%
HTML
3.3%
HTML 5 canvas implementation of Mario written in Ocaml
545
stars
115
commits
OCaml
primary language
Apr 5, 2026
updated
MariOCaml is an HTML 5 canvas web-browser implementation of the Super Mario Bros platformer written exclusively in Ocaml.

MariOcaml is an OCaml implementation of Super Mario Bros. The game includes several basic enemies, blocks, and items, with particle support. The underlying system follows a director model, with the director maintaining state based on game objects and tiles, including Mario, items, and obstacles. The implementation of enemies and items is designed to be easily extensible. Furthermore, MariOcaml supports a game-over and game-win states, as well as score and coin counts, emulating several of the core mechanics of Mario.
The design follows a clean, modular, and extensible system to ensure that more features can easily be added. Levels are procedurally generated (pseudo-randomly), algorithmically creating an environment of textures and objects that are interactable. The procedural generation generally generates a playable map, but due to the nature of random generation, maps may not be the most aesthetically appealing. Additionally, the game is interactive and graphical using js_of_ocaml, which enables cross-compiliation of Ocaml to javascript, allowing MariOcaml to be run in any modern web browser.
The underlying procedural generation utilizes a grid system to generate objects, taking account parameters such as proximity and location. During game-play, the director maintains the game state, including the location and status of both items, enemies, and the character.
If you don't have opam installed, see the official instructions.
Create a local opam switch in the project root and reload the environment. Creating the switch will prompt you to install project dependencies.
opam switch create .
eval $(opam env)
Once all dependencies are installed, run:
make all
to compile the binaries to the _build folder and run the js_of_ocaml cross-compiler.
http://localhost:8000 in a web-browser to run the game!Pull requests fixing bugs, adding functionality, or improving organization are welcome!
MariOCaml was originally conceived for Cornell University's Fall 2015 CS3110 final project.
OCaml
91.8%
CSS
3.9%
HTML
3.3%