no_std_tetris
A minimalist, flexible Tetris implementation in Rust that works in both no_std and standard environments. This crate provides a core Tetris game engine that can be used on embedded systems, in terminal applications, or in any Rust project needing Tetris gameplay.
Features
- Works in
no_stdenvironments, perfect for embedded systems - Generic over random number generation, allowing for platform-specific implementations
- Simple API for game control (move, rotate, etc.)
- Customizable rendering through a generic drawing function
- Complete terminal example using crossterm
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
API Overview
Core Types
Tetris<R>: The main game state, generic over a random number generatorRandomGenerator: Trait for providing random numbers to select new piecesColor: Enum for piece colorsTetromino: Struct representing a tetromino pieces
Game Controls
// Create a new game with a random number generator
let mut game = new;
// Game controls
game.move_left;
game.move_right;
game.move_down;
game.rotate;
// Check game status
if game.is_game_over
Rendering
The library provides a default text-based renderer, but you usually will implement your own. The example implementation is:
Project structure
no_std_tetris/
├── crate_project # the crate and terminal example
├── esp32_c3_example # example implementation on esp32-c3
├── LICENSE
└── README.md