2048.wasm icon indicating copy to clipboard operation
2048.wasm copied to clipboard

2048 written in C and compiled to WebAssembly

2048.wasm

2048 written in C and compiled to WebAssembly

Play

  • Use the arrow keys ( ) to slide the tiles.
  • press n to play over.

Usage

  • Compile C code
$ cd src
$ make game
$ ./play

Note: Make sure you add the appropriate path to SDL2 headers and libs under Makefile.

  • Compile C code to WASM via emscripten
$ emcc -s WASM=1 -s USE_SDL=2 -s USE_SDL_TTF=2 --preload-file src/Nunito-ExtraBold.ttf -O3 -I include -L lib src/main.c -o docs/2048.js

But Why?

why not? Took this up as an experiment; This is just 300 lines of really poor C code which took forever to compile to wasm (rip sdl font).