Skip to content

jschear/twenty_forty_eight

Repository files navigation

twenty_forty_eight

2048 in OCaml, running in the browser with bonsai. Arrow keys control the game.

Game logic is in lib/game.ml, bonsai code is in bin/main.ml.

Dev environment

# Prereq: install opam
# On macOS, homebrew works:
# brew install opam

# Create a local switch for this project, install dependencies from lockfile
opam switch create . --deps-only --locked

# Install lsp and formatter for use in editor
opam install ocamlformat ocaml-lsp-server

Alternatively, there's a nix flake that includes opam and system dependencies. nix develop will drop you into a shell with the system deps installed. Then run the same steps above to install ocaml deps.

Running

# Start an HTTP server for public/
make serve

# Build the JavaScript and copy it into public/
make run

Running tests

dune runtest

TODO

  • Animations
  • Gesture controls for mobile