A terminal-based Tetris implementation using the Lanterna library for Java.
This is a fully functional Tetris game that runs in a terminal-like window. The game follows standard Tetris rules including:
- Line clearing with scoring
- Piece rotation and movement
- Hard drops
- Piece holding
- Next piece preview
- Ghost piece shadows
Game in action showing the main board and next pieces
Game over screen with final score
The easiest way to run the game is using the provided batch files:
run_tetris.bat: Recommended launcher that gives you a choice between windowed and console moderun_windows.bat: Direct launcher for Windows systemsdebug_run.bat: Launches the game with console output visible for debugging
- ←/→: Move piece left/right
- ↓: Move piece down (soft drop)
- ↑ or Z: Rotate piece clockwise
- X: Rotate piece counter-clockwise
- Space: Hard drop (instantly drops the piece)
- C: Hold current piece
- S: Toggle shadow (ghost piece)
- Q: Quit game
| Action | Points |
|---|---|
| Single line | 40 × (level + 1) |
| Double line | 100 × (level + 1) |
| Triple line | 300 × (level + 1) |
| Tetris (4 lines) | 1200 × (level + 1) |
Level increases by 1 for every 10 lines cleared.
-
Game Logic
Board.java: Main game board logicTetromino.java: Tetris piece implementationTetrisGame.java: Game loop and input handling
-
Rendering
BoardRenderer.java: Renders the game boardShapeConstants.java: Tetromino shapes and colorsRenderingConstants.java: UI constants
-
Launchers
WindowsLauncher.java: Windows-specific launcherGameLauncher.java: Platform-independent launcher
- Lanterna: Terminal library for Java
This project uses Maven for dependency management. To build:
mvn clean compileIf you encounter issues:
- Window doesn't appear: Check if it's minimized in your taskbar
- "Failed to initialize terminal": Use the provided batch files instead of direct Maven commands
- Display issues: Try using the debug launcher to see error messages
- Maven errors: Run
clean_fix.batto resolve file locking issues
This project is open source. Feel free to use and modify with attribution.