Giter Site home page Giter Site logo

rust-gamemap's Introduction

rust-gamemap (gamemap) - v0.1.0

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

How to use

Create a map 20x20

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

Update the map (print on the console)

 m.update();

Add some text above and below the map

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

Add some sprites to the map (1 Player, 2 Enemies)

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

Move a sprite on the map

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

Remove sprites (Enemies)

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

Clear the map

m.clear()
 .update();

Installation

Add this line to your Cargo.toml:

[dependencies]
gamemap = "0.1.0"

and then add this line to your main.rs:

extern crate gamemap;

rust-gamemap's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

rust-gamemap's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.