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.
|
1 week ago | |
---|---|---|
.github/workflows | 1 week ago | |
assets/fonts | 1 week ago | |
internal | 1 week ago | |
patch | 1 week ago | |
pkg/config | 1 week ago | |
.gitignore | 1 week ago | |
Makefile | 1 week ago | |
README.md | 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 gamepkg/config
: Contains all game configuration constantsinternal/types
: Defines core data types and enumsinternal/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
- Ebitengine v2.8.8 - 2D game engine for Go
License
This project is open source and available under the MIT License.