diff --git a/src/lib.rs b/src/lib.rs index 759c148..d979ff2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,10 +13,12 @@ mod tile; pub use colour::Colour; pub use config::Config; +pub use entity::Entity; pub use crate::image::Image; pub use music::Music; pub use palette::Palette; pub use scene::Scene; +pub use tile::Tile; #[derive(Debug, Eq, Hash, PartialEq)] pub struct Position { @@ -108,8 +110,8 @@ pub struct Game { config: Config, palettes: Vec, images: Vec, - // todo tiles - // todo things + tiles: Vec, + entities: Vec, // variables: Vec, // triggers: HashMap, music: Vec, @@ -123,6 +125,8 @@ impl Game { let path = PathBuf::from(path); let mut images = Vec::new(); + let mut tiles = Vec::new(); + let mut entities = Vec::new(); let mut music = Vec::new(); let mut palettes = Vec::new(); @@ -155,7 +159,7 @@ impl Game { images_dir.push("palettes"); let image_files = images_dir.read_dir() - .expect("couldn't read images dir"); + .expect("couldn't read image dir"); for file in image_files { let file = file.unwrap(); @@ -163,6 +167,30 @@ impl Game { println!("image found: {:?}", file.file_name()); } + let mut tiles_dir = path.clone(); + tiles_dir.push("palettes"); + + let tiles_files = tiles_dir.read_dir() + .expect("couldn't read tile dir"); + + for file in tiles_files { + let file = file.unwrap(); + tiles.push(Tile::from_file(file.path())); + println!("tile found: {:?}", file.file_name()); + } + + let mut entities_dir = path.clone(); + entities_dir.push("palettes"); + + let entities_files = entities_dir.read_dir() + .expect("couldn't read tile dir"); + + for file in entities_files { + let file = file.unwrap(); + entities.push(Entity::from_file(file.path())); + println!("entity found: {:?}", file.file_name()); + } + let mut game_config = path.clone(); game_config.push("game.toml"); let config = fs::read_to_string(game_config) @@ -170,6 +198,6 @@ impl Game { let config: Config = toml::from_str(&config) .expect("Couldn't parse game config"); - Ok(Game { config, images, palettes, music }) + Ok(Game { config, images, tiles, palettes, music, entities }) } }