add wall property to tile; why did I make "avatar" a tile? smh
This commit is contained in:
parent
3f76ee4f03
commit
0abc64946e
|
@ -1 +0,0 @@
|
|||
images = ["avatar"]
|
|
@ -0,0 +1,2 @@
|
|||
images = ["block"]
|
||||
wall = false
|
14
src/tile.rs
14
src/tile.rs
|
@ -9,6 +9,7 @@ pub struct Tile {
|
|||
/// todo should there be animation options? reverse, random, etc?
|
||||
/// todo do we need a "current frame" property or leave that up to the player implementation?
|
||||
pub images: Vec<String>,
|
||||
pub wall: bool,
|
||||
}
|
||||
|
||||
impl Tile {
|
||||
|
@ -19,13 +20,14 @@ impl Tile {
|
|||
&read_to_string(path).unwrap()
|
||||
).unwrap();
|
||||
|
||||
Tile { name, images: intermediate.images }
|
||||
Tile { name, images: intermediate.images, wall: intermediate.wall }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
struct IntermediateTile {
|
||||
images: Vec<String>,
|
||||
wall: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -35,9 +37,15 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn from_file() {
|
||||
let path = PathBuf::from("src/test-resources/basic/tiles/avatar.toml");
|
||||
let path = PathBuf::from("src/test-resources/basic/tiles/block.toml");
|
||||
let output = Tile::from_file(path);
|
||||
let expected = Tile { name: "avatar".into(), images: vec!["avatar".to_string()] };
|
||||
|
||||
let expected = Tile {
|
||||
name: "block".into(),
|
||||
images: vec!["block".to_string()],
|
||||
wall: false
|
||||
};
|
||||
|
||||
assert_eq!(output, expected);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue