A simple implementation of the classic Tetris game using JavaFX. This project demonstrates core game mechanics like piece movement, rotation, line clearing, scoring, and game-over detection, all rendered using JavaFX components.
✅ Classic Tetris gameplay
✅ Supports standard Tetris shapes (I, J, L, O, S, T, Z)
✅ Smooth block movement and rotation
✅ Score tracking (50 points per cleared line)
✅ Line count display
✅ Game over detection and exit
✅ Simple UI with real-time updates
↑ - Change rotation
↓ - Down (faster down)
→ - Right
← - Left
Java 8 or higher
JavaFX SDK (if not bundled with your JDK)
javac -d out src/com/tetris/tetrisgame/*.javajava -cp out com.tetris.tetrisgame.TetrisAlternatively, you can run it directly from your IDE (IntelliJ IDEA, Eclipse, NetBeans).
| Key | Action |
|---|---|
| LEFT | Move piece left |
| RIGHT | Move piece right |
| DOWN | Move piece down faster |
| UP | Rotate the piece |
src/com/tetris/tetrisgame/
├── Tetris.java // Main class handling game logic, rendering, input
├── Form.java // (Assumed) Represents a tetromino form
├── Controller.java // (Assumed) Provides static methods for movement and piece creationTetris.javaContains the primary game loop, rendering logic, and event handling for key presses.
Form.javaRepresents individual Tetris shapes, holds rectangles for each block of a shape.
Controller.javaResponsible for creating new tetrominoes and controlling their movement.
Grid size: 12 × 24 blocks\
Block size: 25px\
Score: +50 points per cleared row\
Line clear: Rows are checked and removed when full\
Game over: Triggered when new pieces collide at the top
This project is provided as-is for educational purposes. Feel free to modify and enhance it!
