Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Tetris clone in C and compiled to WASM
https://github.com/barrettotte/tetris-wasm

cmake conan raylib tetris wasm

Last synced: 12 days ago
JSON representation

Tetris clone in C and compiled to WASM

Awesome Lists containing this project

README

        

# 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

```sh
# 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
```

```sh
# 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:

```js
{
"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

- https://tetris.wiki/Tetris.wiki
- https://tetris.wiki/Scoring
- https://emscripten.org/
- https://en.wikipedia.org/wiki/Tetromino
- https://emscripten.org/docs/getting_started/downloads.html
- https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)