summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-06 21:20:09 +0100
committertroido <troido@protonmail.com>2020-02-06 21:20:09 +0100
commit45ed2cd201c79fae1c61a4f6f2982a9f5cfbceca (patch)
tree01036ea1ebe1502cfe0645b283dd9595a8b94fae /src/main.rs
parentc18970e8d1003a7b4b3b95b8ade07226bd235f0f (diff)
grass now also loaded from json
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 545245c..1dda2d6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -69,6 +69,7 @@ fn gen_room<'a, 'b>(width: i32, height: i32) -> Room<'a, 'b> {
let mut room = Room::new((width, height));
let assemblages = default_assemblages();
let wall = assemblages["wall"].instantiate(Vec::new(), HashMap::new()).unwrap();
+ let grass = &assemblages["grass"];
for x in 0..width {
room.add_complist(&wall, (x, 0));
room.add_complist(&wall, (x, height - 1));
@@ -79,7 +80,7 @@ fn gen_room<'a, 'b>(width: i32, height: i32) -> Room<'a, 'b> {
}
for x in 1..width-1 {
for y in 1..height-1 {
- room.add_obj(&Grass::new(), (x, y));
+ room.add_complist(&grass.instantiate(Vec::new(), HashMap::new()).unwrap(), (x, y));
}
}
room
@@ -98,12 +99,18 @@ fn default_assemblages() -> HashMap<String, Template> {
]
},
"grass": {
- "arguments": [
- ["sprite", "string", "grass1"]
- ],
+ "arguments": [],
"components": [
["Visible", {
- "sprite": ["arg", "sprite"],
+ "sprite": ["random", [
+ ["string", "grass1"],
+ ["string", "grass2"],
+ ["string", "grass3"],
+ ["string", "grass1"],
+ ["string", "grass2"],
+ ["string", "grass3"],
+ ["string", "ground"]
+ ]],
"height": ["float", 0.1]
}]
]