barrettotte / tetris-wasm

Tetris clone in C and compiled to WASM

Home Page:https://barrettotte.github.io/tetris-wasm/

Repository from Github https://github.combarrettotte/tetris-wasmRepository from Github https://github.combarrettotte/tetris-wasm

tetris-wasm

Tetris clone in C and compiled to WASM.

This was made to learn the basics of Raylib, WASM, CMake, Conan, and Ninja.

docs/screenshot.png

WASM build served at https://barrettotte.github.io/tetris-wasm/

Controls

  • Left: , A
  • Right: , D
  • Rotate: , W
  • Down: , S
  • Fast drop: SPACE
  • Restart: R

Development

Dependencies: CMake, Conan, Ninja, Emscripten

# native build
conan install . --profile=profiles/default --output-folder=build --build=missing
cmake -G Ninja -B build
ninja -C build

# build and run binary
ninja -C build run
# wasm build
conan install . --profile=profiles/wasm --output-folder=build-wasm --build=missing
cmake -G Ninja -B build-wasm -DEMSCRIPTEN=ON
ninja -C build-wasm

# build and serve wasm binary at http://localhost:1337
ninja -C build-wasm serve

VS Code

For intellisense, add compileCommands property:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            // ...
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}

Unimplemented Features

  • Tetromino ghost/shadow
  • Next tetromino preview
  • Tetromino hold
  • Levels
  • Pause screen
  • Audio
  • Limited scoring
  • No high score recording
  • Probably more I didn't notice

References

About

Tetris clone in C and compiled to WASM

https://barrettotte.github.io/tetris-wasm/

License:MIT License


Languages

Language:C 88.7%Language:CMake 8.9%Language:Python 2.4%