Expand description
no_std business logic for tiny games.
MicroGames is the part of a game that should not know whether it is being displayed in a terminal, framebuffer, GPU window, serial shell, embedded display, or custom OS UI. It owns rules and state transitions; your platform owns events, input, timing, audio, and output.
The crate currently includes engines for:
- Tetris-like falling blocks via
Game snakeminesweeperbejewledchess- a terminal-oriented Tetris shell adapter in
shell
§Basic Tetris Loop
use microgames::{Lcg32, NoopEvents, Rotation};
let mut rng = Lcg32::new(0xC11C_7E75);
let mut events = NoopEvents;
let mut game = microgames::Game::<10, 24, 4>::new(&mut rng, &mut events);
game.move_left();
game.rotate(Rotation::Cw);
game.soft_drop(&mut rng, &mut events);
for y in game.hidden_rows()..game.height_total() {
for x in 0..game.width() {
let cell = game.cell_view_at(x, y, true);
let _ = cell;
}
}§Events
Game engines report meaningful side effects through event traits. A renderer, audio system, logger, network sync layer, or test harness can implement only the callbacks it needs.
use microgames::{Rgb8, TetrisEvents};
struct Effects;
impl TetrisEvents for Effects {
fn on_block_placed(&mut self, color: Rgb8, x: usize, y: usize) {
let _ = (color, x, y);
}
}Use NoopEvents when you only want to drive the rules.
Modules§
- bejewled
- Bejeweled-style match-3 game logic. Bejeweled-style match-3 business logic.
- chess
- Chess board, legal move, castling, promotion, en-passant, and state logic. Chess board and legal move logic.
- minesweeper
- Minesweeper board generation, reveal, flag, chord, and win/loss logic. Minesweeper business logic.
- shell
- A terminal-oriented Tetris shell adapter built on
core::fmt. Terminal-oriented Tetris shell adapter. - snake
- Snake movement, growth, food, scoring, and collision logic. Snake business logic.
Structs§
- Block
- Cell
View - Feature
Flags - Compact set of enabled
Featurevalues. - Game
- Lcg32
- Tiny deterministic linear-congruential random source.
- Level
State - Built-in Tetris-like level, score, and feature progression.
- Move
Suggestion - Noop
Events - Event sink that ignores every callback.
- Piece
- Active Tetris-like piece.
- Rgb8
- Small RGB color used by the built-in game logic and renderer adapters.
Enums§
- Feature
- Feature unlocked by the built-in Tetris level progression.
- Layer
- Piece
Kind - Tetris-like piece shape.
- Rotation
- Rotation direction for Tetris-like pieces.
- Tick
Result - Result of a Tetris-like gravity or drop tick.
Constants§
- MAX_
PIECE_ CELLS - Maximum number of cells a Tetris-like piece can occupy.
Traits§
- Random
Source - Random source used by the games that need deterministic randomness.
- Tetris
Events - Event hooks emitted by the Tetris-like engine.