A professional, feature-complete Tetris implementation in Rust using the macroquad game engine. This project demonstrates clean, modular Rust code architecture and serves as an excellent example of game development practices.
🔗 GitHub Repository: https://github.com/gendonholaholo/rust_tetris.git
This project is maintained by gendonholaholo and showcases professional Rust development practices for game development.
- Complete Tetris Gameplay: All 7 standard Tetrimino pieces (I, O, T, S, Z, J, L)
- Advanced Rotation System: Wall-kick rotation with piece-specific kick tables
- Line Clearing: Animated line clearing with visual feedback
- Level Progression: Speed increases every 10 lines cleared
- Professional Scoring: Standard Tetris scoring system with level multipliers
- Next Piece Preview: Shows the upcoming piece
- Hold System: Hold and swap pieces with visual feedback
- Ghost Piece: Transparent preview showing landing position
- Pause Functionality: Game can be paused and resumed
- Game Over Detection: Proper game over conditions and restart functionality
- Beveled Blocks: 3D-styled blocks with highlights and shadows
- Smooth Animations: Line clearing animations with blinking effects
- Clean UI: Minimalist interface with score, level, and line counters
- Professional Layout: Well-organized grid and preview areas
- Modular Architecture: Clean separation of concerns across modules
- Comprehensive Documentation: Extensive doc comments and code organization
- Performance Optimized: Efficient rendering and game loop
- Rust Idioms: Follows Rust best practices and conventions
| Key | Action |
|---|---|
| ← → | Move piece left/right |
| ↑ | Rotate piece clockwise |
| ↓ | Soft drop (faster fall) |
| Space | Hard drop (instant drop) |
| C or Shift | Hold/swap piece |
| P | Pause/unpause game |
| R | Restart (when game over) |
rust_tetris/
├── Cargo.toml # Project configuration and dependencies
└── src/
├── main.rs # Entry point and game loop
├── constants.rs # Game configuration constants
├── piece.rs # Tetrimino definitions and logic
├── grid.rs # Game board and line clearing
├── game.rs # Core game state and mechanics
├── input.rs # Input handling and controls
└── rendering.rs # Visual rendering system
constants.rs: All game parameters, colors, layout settings, and configurationpiece.rs: Tetrimino shapes, rotations, spawning, and piece logicgrid.rs: Game board state, collision detection, line clearing, and validationgame.rs: Central game state, piece movement, scoring, and level progressioninput.rs: Keyboard input handling with proper timing and repeat logicrendering.rs: All visual rendering including UI, animations, and effectsmain.rs: Application entry point and main game loop
- Single Responsibility: Each module has a clear, focused purpose
- Clean APIs: Modules interact through well-defined public interfaces
- State Management: Single GameState as the source of truth
- Separation of Concerns: Logic, input, and rendering are completely separate
- Documentation: Comprehensive doc comments for all public APIs
- Rust 1.70+ (2021 edition)
- Linux/macOS/Windows with graphics support
# Clone the repository
git clone https://github.com/gendonholaholo/rust_tetris.git
cd rust_tetris
# Build and run in debug mode
cargo run
# Build optimized release version
cargo run --release
# Check for compilation errors
cargo check- macroquad 0.4: Cross-platform game framework
- rand 0.8: Random number generation for piece spawning
- Single (1 line): 100 × level
- Double (2 lines): 300 × level
- Triple (3 lines): 500 × level
- Tetris (4 lines): 800 × level
- Level increases every 10 lines cleared
- Fall speed increases with each level
- Minimum fall rate prevents unplayable speeds
- Hold one piece and swap with current piece
- Hold is disabled after use until next piece locks
- Visual feedback shows when hold is unavailable
- Error Handling: Pragmatic use of
expect()for internal consistency - Memory Safety: Leverages Rust's ownership system
- Performance: Efficient algorithms and minimal allocations
- Maintainability: Clear structure and comprehensive documentation
- Wall Kicks: Proper rotation behavior near walls and other pieces
- Piece Spawning: Correct spawn positions with game over detection
- Animation System: Smooth line clearing with timing control
- Input Handling: Proper key repeat and timing for responsive controls
- 3D Block Effects: Beveled edges with highlights and shadows
- Color Scheme: Professional dark theme with vibrant piece colors
- UI Layout: Clean, organized interface with all necessary information
- Animations: Satisfying visual feedback for game events
This implementation serves as an excellent example of:
- Clean Architecture: Modular design with clear separation of concerns
- Rust Best Practices: Idiomatic Rust code following community conventions
- Game Development: Professional game architecture and state management
- Documentation: Comprehensive comments and architectural documentation
Potential improvements for future versions:
- High score persistence
- Customizable controls
- Sound effects and music
- Multiple difficulty modes
- Network multiplayer
- Advanced graphics effects
This project demonstrates professional Rust development practices and is suitable for educational purposes, portfolio projects, and as a foundation for further game development.
This project welcomes contributions! Feel free to:
- Report bugs and issues
- Suggest new features
- Submit pull requests
- Improve documentation
Please visit the GitHub repository to contribute.
gendonholaholo - GitHub Profile
Rust Tetris - Showcasing elegant Rust architecture in game development.