1个不稳定版本
0.1.0 | 2022年7月15日 |
---|
#1040 in 游戏开发
14KB
257 行
playt (在终端中玩耍)
读音像盘子,playt中乐趣无穷
你好,世界!
// 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();
}
}
结果
依赖
~0.2–0.9MB
~15K SLoC