Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Rust Tetris

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.

Repository

🔗 GitHub Repository: https://github.com/gendonholaholo/rust_tetris.git

This project is maintained by gendonholaholo and showcases professional Rust development practices for game development.

Features

Core Game Mechanics

  • 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

Modern Tetris Features

  • 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

Visual Polish

  • 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

Technical Excellence

  • 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

Controls

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)

Project Structure

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

Architecture Overview

Module Responsibilities

  • constants.rs: All game parameters, colors, layout settings, and configuration
  • piece.rs: Tetrimino shapes, rotations, spawning, and piece logic
  • grid.rs: Game board state, collision detection, line clearing, and validation
  • game.rs: Central game state, piece movement, scoring, and level progression
  • input.rs: Keyboard input handling with proper timing and repeat logic
  • rendering.rs: All visual rendering including UI, animations, and effects
  • main.rs: Application entry point and main game loop

Key Design Principles

  1. Single Responsibility: Each module has a clear, focused purpose
  2. Clean APIs: Modules interact through well-defined public interfaces
  3. State Management: Single GameState as the source of truth
  4. Separation of Concerns: Logic, input, and rendering are completely separate
  5. Documentation: Comprehensive doc comments for all public APIs

Building and Running

Prerequisites

  • Rust 1.70+ (2021 edition)
  • Linux/macOS/Windows with graphics support

Quick Start

# 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

Dependencies

  • macroquad 0.4: Cross-platform game framework
  • rand 0.8: Random number generation for piece spawning

Game Rules

Scoring System

  • Single (1 line): 100 × level
  • Double (2 lines): 300 × level
  • Triple (3 lines): 500 × level
  • Tetris (4 lines): 800 × level

Level Progression

  • Level increases every 10 lines cleared
  • Fall speed increases with each level
  • Minimum fall rate prevents unplayable speeds

Hold System

  • Hold one piece and swap with current piece
  • Hold is disabled after use until next piece locks
  • Visual feedback shows when hold is unavailable

Implementation Highlights

Professional Code Quality

  • 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

Advanced Features

  • 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

Visual Polish

  • 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

Code Quality

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

Future Enhancements (V2.0)

Potential improvements for future versions:

  • High score persistence
  • Customizable controls
  • Sound effects and music
  • Multiple difficulty modes
  • Network multiplayer
  • Advanced graphics effects

License

This project demonstrates professional Rust development practices and is suitable for educational purposes, portfolio projects, and as a foundation for further game development.

Contributing

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.

Author

gendonholaholo - GitHub Profile


Rust Tetris - Showcasing elegant Rust architecture in game development.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages