#map #console #board #game

gamemap

A small 2D Map library for console games in Rust

1 个不稳定版本

使用旧的 Rust 2015

0.1.0 2017年11月6日

#1201 in 开发工具

MIT 许可证

7KB
103

rust-gamemap (gamemap) - v0.1.0

A small 2D Map library for console games in Rust.

如何使用

Create a map 20x20

let mut m = gamemap::Map::new(20, 20);

更新地图(在控制台上打印)

 m.update();

在地图上方和下方添加一些文本

let mut utext = String::from("This is some text above the map!!!");
let mut ltext = String::from("This is some text below the map!!!");

m.set_uppertext(utext)
 .set_lowertext(ltext)
 .update();

在地图上添加一些精灵(1个玩家,2个敌人)

let mut sprites = vec![((15u32, 7u32), 'P'),
                       ((9u32, 12u32), 'E'),
                       ((11u32, 6u32), 'E')];

m.add_sprite(sprites[0])
 .add_sprite(sprites[1])
 .add_sprite(sprites[2])
 .update();

在地图上移动一个精灵

m.move_sprite(sprites[0].0, (1u32, 1u32))
 .update();

删除精灵(敌人)

m.remove_sprite(sprites[1].0)
 .remove_sprite(sprites[2].0)
 .update();

清除地图

m.clear()
 .update();

安装

将此行添加到您的 Cargo.toml 中

[dependencies]
gamemap = "0.1.0"

然后将其添加到您的 main.rs 中

extern crate gamemap;

无运行时依赖项