#engine #gamedev #game-engine #cli #cli-game

Clig

一个用于在命令行中制作游戏的命令行界面(CLI)游戏引擎

1 个不稳定版本

0.1.1 2020年10月3日
0.1.0 2020年10月3日

#1036 in 游戏开发

每月 43 次下载

GPL-3.0-or-later

15KB
142

Clig

一个简单的游戏引擎,用于制作简单的命令行界面(CLI)游戏

功能

地图

pub fn new(width: u8, height: u8, delimiter: char) -> GameMap
pub fn setsize(&mut self, width: u8, height: u8)
pub fn setdelimiter(&mut self, delimiter: char)
pub fn create(&self)
pub fn drawentities(&self, entities: &Vec<Entity>)

实体

pub fn new(x: u8, y: u8, isplayer: bool, symbol: char, canmove: bool) -> Entity
pub fn newdefault(symbol: char) -> Entity
pub fn get_pos(&self) -> (u8, u8)
pub fn move_to(&mut self, x: u8, y: u8)
pub fn symbol(&self) -> char

文档

创建一个新的空地图并在屏幕上显示它

let map = GameMap::new(50,8,"#");
map.create();

调整大小并更改边界

let mut map = GameMap::new(50, 8, "#");
map.create();
map.setsize(40, 8);
map.create();
map.setdelimiter('*');
map.create();

绘制一些实体

let mut map = GameMap::new(50,10,'#');
let entities: Vec<Entity> = vec![Entity::new(10,15,false, '8', false)] 
map.drawentities(entities); // Won't draw anything cause 15 > 10
let mut map = GameMap::new(50,10,'#');
let entities: Vec<Entity> = vec![Entity::new(10,8,false, '8', false), Entity::newdefault('0')] 
map.drawentities(entities); // Will draw a 8 at (10;8) and a 0 at (1;1)

绘制实体后移动它

let mut map = GameMap::new(50,10,'#');
let mut entities: Vec<Entity> = vec![Entity::newdefault('0')] 
map.drawentities(&entities); // Will draw a 0 at (1;1)
entities[0].move_to(5,2);
map.drawentities(&entities); // Will draw a 0 at (5;2)

无运行时依赖