Clig

Crates.ioClig
lib.rsClig
version0.1.1
sourcesrc
created_at2020-10-03 10:56:27.042072
updated_at2020-10-03 11:03:25.537913
descriptionA CLI Game engine to make games in CLI
homepage
repositoryhttps://github.com/Wafelack/Clig
max_upload_size
id295715
size43,426
Wafelack (Wafelack)

documentation

https://github.com/Wafelack/Clig/blob/master/README.md

README

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)
Commit count: 117

cargo fmt