Skip to content
Snippets Groups Projects
Commit 95e1fe19 authored by Matthew Hall's avatar Matthew Hall
Browse files

Add example to README

parent 2eb7e8aa
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,29 @@ ...@@ -5,6 +5,29 @@
Read maps from the [Tiled Map Editor](http://www.mapeditor.org/) into rust for use in video games. It is game engine agnostic and pretty barebones at the moment. Documentation is available [on rust-ci](http://rust-ci.org/mattyhall/rs-tiled/doc/tiled/). Read maps from the [Tiled Map Editor](http://www.mapeditor.org/) into rust for use in video games. It is game engine agnostic and pretty barebones at the moment. Documentation is available [on rust-ci](http://rust-ci.org/mattyhall/rs-tiled/doc/tiled/).
### Example
```rust
extern crate serialize;
extern crate xml;
extern crate tiled;
use std::io::File;
use std::io::BufferedReader;
use xml::reader::EventReader;
use tiled::parse;
fn main() {
let file = File::open(&Path::new("assets/tiled_base64_zlib.tmx")).unwrap();
println!("Opened file");
let reader = BufferedReader::new(file);
let mut parser = EventReader::new(reader);
let map = parse(&mut parser).unwrap();
println!("{}", map);
println!("{}", map.get_tileset_by_gid(22));
}
```
### Things missing ### Things missing
There are a few things missing at the moment: There are a few things missing at the moment:
...@@ -15,6 +38,7 @@ There are a few things missing at the moment: ...@@ -15,6 +38,7 @@ There are a few things missing at the moment:
* Image layers * Image layers
* A nice API. At the moment you can access attributes and properties, find tilesets by GID and loop through the tiles. This leaves a user of the library with a bit to do. * A nice API. At the moment you can access attributes and properties, find tilesets by GID and loop through the tiles. This leaves a user of the library with a bit to do.
### Licences
assets/tilesheet.png by Buch (http://blog-buch.rhcloud.com/) assets/tilesheet.png by Buch (http://blog-buch.rhcloud.com/)
Licenced under MIT Licenced under MIT
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment