# Java-Tetris **Repository Path**: chenyanghaorui/Java-Tetris ## Basic Information - **Project Name**: Java-Tetris - **Description**: Java小游戏--俄罗斯方块 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-29 - **Last Updated**: 2025-08-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: Java ## README # Java-Tetris A classic Tetris game implemented in Java. ## Project Features - Object-oriented design with a clear class structure - Supports basic operations such as block falling, horizontal movement, and rotation - Automatic scoring and row elimination functionality - Graphical interface implemented using Swing ## Main Classes - `Cell`: Represents an individual cell within a block - `Tetromino`: Represents various block types (I, J, L, O, S, T, Z) - `Tetris`: Core game logic and interface rendering - `GameFrame`: Game main window ## How to Run 1. Ensure that a Java development environment is installed 2. Clone the project to your local machine 3. Compile and run the `GameFrame` class Example run code: ```java public static void main(String[] args) throws Exception { JFrame f = new JFrame("Tetris"); Tetris t = new Tetris(); f.add(t); f.setSize(540, 590); f.setLocationRelativeTo(null); f.setResizable(false); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); t.action(); } ``` ## Controls - Left Arrow: Move the block to the left - Right Arrow: Move the block to the right - Down Arrow: Accelerate the block's fall - Up Arrow: Rotate the block ## Game Screenshot ![Game Screenshot](tetris.png) ## License This project uses the MIT License. Please check the LICENSE file for details.