Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dimchtz/rust-gamemap
A small 2D Map library for console games in Rust.
https://github.com/dimchtz/rust-gamemap
2d console game game-development game-map gamemaps map rust rust-gamemap sprite sprites
Last synced: about 1 month ago
JSON representation
A small 2D Map library for console games in Rust.
- Host: GitHub
- URL: https://github.com/dimchtz/rust-gamemap
- Owner: DimChtz
- License: mit
- Created: 2017-11-06T22:43:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-06T22:51:28.000Z (about 7 years ago)
- Last Synced: 2024-11-21T22:41:57.432Z (about 2 months ago)
- Topics: 2d, console, game, game-development, game-map, gamemaps, map, rust, rust-gamemap, sprite, sprites
- Language: Rust
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rust-gamemap (gamemap) - v0.1.0
A small 2D Map library for console games in Rust.# How to use
#### Create a map 20x20
```rust
let mut m = gamemap::Map::new(20, 20);
```
#### Update the map (print on the console)
```rust
m.update();
```
#### Add some text above and below the map
```rust
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)
```rust
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
```rust
m.move_sprite(sprites[0].0, (1u32, 1u32))
.update();
```
#### Remove sprites (Enemies)
```rust
m.remove_sprite(sprites[1].0)
.remove_sprite(sprites[2].0)
.update();
```
#### Clear the map
```rust
m.clear()
.update();
```# Installation
Add this line to your Cargo.toml:
```toml
[dependencies]
gamemap = "0.1.0"
```and then add this line to your main.rs:
```rust
extern crate gamemap;
```