Home

Awesome

Elm 2048

An Elm version of Gabriele Cirulli's 2048 game

Deployed to Github Pages: https://stepheneb.github.io/elm-2048/

MIT License

I wrote this to learn more about Elm.

Possibly helpful/useful/interesting features:

  1. Save game state to local storage.
  1. Load game state on application startup.
  1. Model Tiles using Html.Keyed to allow CSS animations to work effectively.
  2. Use Events.onKeyDown and Subscriptions to handle arrow keys for Tile movement.
    • Additional JavaScript code to prevent arrow keyboard events bubbling and causing page scroll.
  3. Use JavaScript and incoming Port to turn touch interface swipes into Tile movements.
  4. Game state record is nested one-level deep in Model.
    • Helper functions work with Update Msg branches to cleanly handle game state record manipulation and updates.

This project is bootstrapped with Create Elm App. Readme generated by elm-app: elm-app-readme.md).

Build dependencies:

To build locally:

% git clone https://github.com/stepheneb/elm-2048
% cd elm-2048
% nvm use
% yarn
% yarn build-css
% yarn start

Local development run:

% yarn start

If you are also changing the scss styles open a second shell and run:

$ yarn watch-css

Deploy to Github Pages:

% yarn build-deploy