Skip to content

BryceTieu/Tetris

Repository files navigation

Terminal Tetris

A terminal-based Tetris implementation using the Lanterna library for Java.

Overview

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

Screenshots

Tetris Gameplay Game in action showing the main board and next pieces

Game Over Screen Game over screen with final score

How to Play

Running the Game

The easiest way to run the game is using the provided batch files:

  1. run_tetris.bat: Recommended launcher that gives you a choice between windowed and console mode
  2. run_windows.bat: Direct launcher for Windows systems
  3. debug_run.bat: Launches the game with console output visible for debugging

Controls

  • ←/→: 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

Scoring System

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.

Technical Details

Project Structure

  • Game Logic

    • Board.java: Main game board logic
    • Tetromino.java: Tetris piece implementation
    • TetrisGame.java: Game loop and input handling
  • Rendering

    • BoardRenderer.java: Renders the game board
    • ShapeConstants.java: Tetromino shapes and colors
    • RenderingConstants.java: UI constants
  • Launchers

    • WindowsLauncher.java: Windows-specific launcher
    • GameLauncher.java: Platform-independent launcher

Dependencies

Building from Source

This project uses Maven for dependency management. To build:

mvn clean compile

Troubleshooting

If you encounter issues:

  1. Window doesn't appear: Check if it's minimized in your taskbar
  2. "Failed to initialize terminal": Use the provided batch files instead of direct Maven commands
  3. Display issues: Try using the debug launcher to see error messages
  4. Maven errors: Run clean_fix.bat to resolve file locking issues

License

This project is open source. Feel free to use and modify with attribution.

About

Tetris game made completly in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published