Skip to content

A Tetris library implemented in Go, and also a Tetris game that can be run in the terminal or browser (based on WASM)

License

yhlooo/go-tetris

Repository files navigation

简体中文 | English

Most content of this article is machine-translated from README_CN.md using DeepSeek. :)


GitHub License GitHub Release release

go-tetris

This project is a Tetris library implemented in Go, and also a playable Tetris game that runs in browsers (based on Wasm) or terminals.

Play!

In Browser

web-ui

Visit Tetris to start playing right away.

In Terminal

tty-ui

Install and run Tetris via one of the following methods:

Download Prebuilt Binary:

Download the executable binary from Releases, unzip it, and place the tetris file in any directory in your $PATH.

Then execute:

tetris

Use Docker:

docker run --rm --name tetris -it ghcr.io/yhlooo/tetris:latest

Build from Source:

# Download and build the source
go install github.com/yhlooo/go-tetris/cmd/tetris@latest
# Run
$(go env GOPATH)/bin/tetris

Build the Project

Terminal UI:

go run ./cmd/tetris

Web UI:

GOOS=js GOARCH=wasm go build -o web/app.wasm ./cmd/tetris-wasm && go run ./cmd/tetris-wasm

Then open http://localhost:8000 in your browser.

Build Your Own Tetris

This project is not just a playable Tetris game, but also an easy-to-integrate Tetris library. You can use it to build your own Tetris game. Refer to the Tetris interface for API details.

Note: This package is still in its very early stage, and the interfaces may have BREAKING CHANGES.

Implemented Features

  • Randomizer
    • 7-Bag
    • Customizable
  • Rotation System
    • Super Rotation System (SRS)
    • Customizable
  • Scoring System
    • Follow the Tetris Guidelines
      • Soft Drop
      • Hard Drop
      • T-Spin
      • T-Spin Single
      • T-Spin Double
      • T-Spin Triple
      • Single Line Clear
      • Double Line Clear
      • Triple Line Clear
      • Tetris
      • Back-to-Back
    • Customizable
  • Hold
  • Piece preview
  • Ghost piece
  • Lock Down Delay

Acknowledgements

About

A Tetris library implemented in Go, and also a Tetris game that can be run in the terminal or browser (based on WASM)

Resources

License

Stars

Watchers

Forks

Packages