microgames 0.1.0

no_std microgame business logic: plug in events, input, and output
Documentation
  • Coverage
  • 18.02%
    60 out of 333 items documented1 out of 192 items with examples
  • Size
  • Source code size: 133.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.3 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • t4ce/MicroGames
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • t4ce

MicroGames

crates.io docs.rs license

MicroGames is a no_std business-logic layer for tiny games.

MicroGames CLI Tetris example

It is designed for the part of a game that should not care whether the screen is a terminal, a framebuffer, a GPU window, a serial shell, an embedded display, or a custom OS UI. You plug in input, random numbers, events, and output; the crate keeps the rules, state transitions, scoring, and board queries.

Current game engines:

  • Tetris-like falling blocks
  • Snake
  • Minesweeper
  • Bejeweled-style match 3
  • Chess move/state logic

Shape

The crate is intentionally small and direct:

  • #![no_std]
  • no allocator requirement for the core engines
  • fixed-size const-generic boards
  • deterministic RandomSource trait
  • event traits for sounds, score changes, row clears, mine reveals, food spawns, and game-over hooks
  • query methods for renderers, terminals, tests, and custom shells

The library does not own your event loop or output target. Your platform drives ticks and inputs, then renders from the game state.

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 And Output

Events are callbacks owned by the integration layer. For Tetris:

use microgames::{Rgb8, TetrisEvents};

struct AudioAndFx;

impl TetrisEvents for AudioAndFx {
    fn on_block_placed(&mut self, color: Rgb8, x: usize, y: usize) {
        let _ = (color, x, y);
    }

    fn on_music(&mut self, track_id: u8) {
        let _ = track_id;
    }
}

That is the main contract of MicroGames: the library decides what happened; your platform decides what it means visually, audibly, or operationally.

CLI Proof

The included CLI example is a small std shim around the same no_std shell adapter used by older TRUEOS UI demos:

cargo run --example cli_tetris

It is deliberately plain. The interesting part is that the game logic and shell renderer do not depend on std, TRUEOS, or a particular terminal backend.

Documentation

Publishing Check

Before publishing:

cargo test
cargo run --example cli_tetris
cargo package --list
cargo publish --dry-run