Crates.io | Clig |
lib.rs | Clig |
version | 0.1.1 |
source | src |
created_at | 2020-10-03 10:56:27.042072 |
updated_at | 2020-10-03 11:03:25.537913 |
description | A CLI Game engine to make games in CLI |
homepage | |
repository | https://github.com/Wafelack/Clig |
max_upload_size | |
id | 295715 |
size | 43,426 |
Simple game engine to make simple CLI games
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
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)