You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
huyinsong 0e6338a383 添加退出说明 6 days ago
.github/workflows 生成可运行的版本 1 week ago
assets 添加windows和macos分发版 1 week ago
internal 添加退出说明 6 days ago
pkg/config 生成可运行的版本 1 week ago
.gitignore 生成可运行的版本 1 week ago
BUILD.md 添加windows和macos分发版 1 week ago
Makefile 添加windows和macos分发版 1 week ago
README.md 添加中文支持 1 week ago
build.sh 添加windows和macos分发版 1 week ago
go.mod 添加中文支持 1 week ago
go.sum 添加中文支持 1 week ago
main.go 添加中文支持 1 week ago

README.md

Tetris Game

A classic Tetris game implemented in Go using the Ebitengine game engine.

Features

  • Classic Tetris gameplay
  • Ghost piece preview
  • Next piece preview
  • Line clearing with scoring
  • Progressive difficulty levels
  • Smooth controls with wall kicks

Project Structure

tetris/
├── main.go                 # Application entry point
├── go.mod                  # Go module definition
├── go.sum                  # Go module checksums
├── assets/                 # Game assets (future use)
├── internal/               # Internal packages
│   ├── game/              # Core game logic
│   │   └── game.go        # Game state and rendering
│   ├── tetromino/         # Tetromino (falling pieces) logic
│   │   └── tetromino.go   # Piece shapes, rotation, movement
│   └── types/             # Shared type definitions
│       └── types.go       # Block types and colors
└── pkg/                   # Public packages
    └── config/            # Configuration constants
        └── config.go      # Game configuration and constants

Architecture

The project follows Go best practices with a clean package structure:

  • main.go: Entry point that initializes the game
  • pkg/config: Contains all game configuration constants
  • internal/types: Defines core data types and enums
  • internal/tetromino: Handles tetromino piece logic (shapes, rotation, movement)
  • internal/game: Core game mechanics (board state, input handling, rendering)

Controls

  • Left/Right Arrow: Move piece horizontally
  • Up Arrow: Rotate piece clockwise
  • Down Arrow: Soft drop (faster falling)
  • Space: Hard drop (instant drop)
  • L: Switch language (English ⇄ 中文)
  • R (when game over): Restart game

中文支持 / Chinese Support

游戏支持中文界面!启动游戏后按 L 键 切换到中文模式。

The game supports Chinese interface! Press L key after starting the game to switch to Chinese mode.

参见 中文使用指南 了解详细说明。

See Chinese Usage Guide for detailed instructions.

Building and Running

# Run the game
go run .

# Build executable
go build -o tetris
./tetris

Dependencies

License

This project is open source and available under the MIT License.