playt 0.1.0

Playt is a game library for the terminal
Documentation
  • Coverage
  • 22.77%
    23 out of 101 items documented0 out of 25 items with examples
  • Size
  • Source code size: 22.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.6 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • kaiserthe13th/playt
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kaiserthe13th

playt (play with the terminal)

read like plate, playt with fun

Hello, World!

// in examples/hello.rs

use pancurses::Input;
use playt::prelude::*;

fn main() {
    let mut game = Game::with_colors(())
        .expect("couldn't initialize with colors");
    
    let mut stage = Stage::new(())
        .clear_on_resize(true)
        .draw(|_, _, win| -> Result<(), ()> {
            win.with_attr(color::GREEN_ON_BLACK, |win| {
                let greeting = "Hello, World!";
                win.mvprintw(win.get_mid_y(0), win.get_mid_x(greeting.len() as i32), greeting);
            });
            Ok(())
        })
        .update(|game, _, input| {
            if let Some(Input::Character('q')) = input {
                game.stop();
            }
            Ok(())
        })
        .build();
    
    while game.is_running() {
        game.perform(&mut stage).unwrap();
    }
}

Result: A terminal screen with "Hello, World!" written in green in the middle of it