+
Skip to content

aprock/tetrust

Repository files navigation

Tetrust 🎮

Tetrust Game Screenshot

A simple Tetris clone built in Rust using the Raylib graphics library. This project was created as a learning exercise to explore Rust game development and understand the fundamentals of building classic arcade games.

Try the wasm version

Inspiration

This project is based on the tutorial "Creating Tetris in C++ with raylib - Beginner Tutorial (OOP)" by Programming With Nick, adapted from C++ to Rust to explore Rust's unique features and syntax.

Features

  • Classic Tetris Gameplay: All standard Tetris mechanics including line clearing, block rotation, and increasing difficulty
  • Seven Tetris Pieces: Complete set of tetrominoes (I, O, T, S, Z, J, L blocks)
  • Real-time Scoring: Track your performance with a live score counter
  • Next Block Preview: See what piece is coming up next
  • Game Over Detection: Proper end-game state handling
  • Smooth 60 FPS Gameplay: Responsive controls and fluid animation

Technical Implementation

The project is structured with clean separation of concerns:

  • main.rs - Game loop and rendering setup
  • game.rs - Core game logic and state management
  • block.rs - Tetromino piece definitions and behavior
  • grid.rs - Game board management and line clearing
  • colors.rs - Color scheme and visual styling
  • timer.rs - Game timing and automatic piece dropping

Dependencies

  • Raylib: Cross-platform graphics and game programming library
  • Rand: Random number generation for piece selection

Controls

  • Arrow Keys: Move and rotate pieces
  • Down Arrow: Soft drop (faster falling)

Learning Goals

This project demonstrates:

  • Rust ownership and borrowing principles
  • Game loop architecture
  • 2D graphics programming
  • State management in interactive applications
  • Modular code organization

Getting Started

# Clone and run
cargo run

Make sure you have the required font file in the font/ directory for proper text rendering.


Built with Rust 🦀 | A simple project for learning and playing with game development

About

playing with rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载