1 unstable release

0.1.1 Oct 3, 2020
0.1.0 Oct 3, 2020

#1036 in Game dev

43 downloads per month

GPL-3.0-or-later

15KB
142 lines

Clig

Simple game engine to make simple CLI games

Functions

Map

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>)

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

Documentation

Create a new empty map and display it to the screenx:

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

Resize it and change the border:

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

Draw some entities :

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)

Move an entity after drawing it :

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)

No runtime deps