tiles and entities
This commit is contained in:
parent
6637d87d45
commit
b72e8f5ac8
36
src/lib.rs
36
src/lib.rs
|
@ -13,10 +13,12 @@ mod tile;
|
||||||
|
|
||||||
pub use colour::Colour;
|
pub use colour::Colour;
|
||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
|
pub use entity::Entity;
|
||||||
pub use crate::image::Image;
|
pub use crate::image::Image;
|
||||||
pub use music::Music;
|
pub use music::Music;
|
||||||
pub use palette::Palette;
|
pub use palette::Palette;
|
||||||
pub use scene::Scene;
|
pub use scene::Scene;
|
||||||
|
pub use tile::Tile;
|
||||||
|
|
||||||
#[derive(Debug, Eq, Hash, PartialEq)]
|
#[derive(Debug, Eq, Hash, PartialEq)]
|
||||||
pub struct Position {
|
pub struct Position {
|
||||||
|
@ -108,8 +110,8 @@ pub struct Game {
|
||||||
config: Config,
|
config: Config,
|
||||||
palettes: Vec<Palette>,
|
palettes: Vec<Palette>,
|
||||||
images: Vec<Image>,
|
images: Vec<Image>,
|
||||||
// todo tiles
|
tiles: Vec<Tile>,
|
||||||
// todo things
|
entities: Vec<Entity>,
|
||||||
// variables: Vec<Variable>,
|
// variables: Vec<Variable>,
|
||||||
// triggers: HashMap<String, ScriptCollection>,
|
// triggers: HashMap<String, ScriptCollection>,
|
||||||
music: Vec<Music>,
|
music: Vec<Music>,
|
||||||
|
@ -123,6 +125,8 @@ impl Game {
|
||||||
let path = PathBuf::from(path);
|
let path = PathBuf::from(path);
|
||||||
|
|
||||||
let mut images = Vec::new();
|
let mut images = Vec::new();
|
||||||
|
let mut tiles = Vec::new();
|
||||||
|
let mut entities = Vec::new();
|
||||||
let mut music = Vec::new();
|
let mut music = Vec::new();
|
||||||
let mut palettes = Vec::new();
|
let mut palettes = Vec::new();
|
||||||
|
|
||||||
|
@ -155,7 +159,7 @@ impl Game {
|
||||||
images_dir.push("palettes");
|
images_dir.push("palettes");
|
||||||
|
|
||||||
let image_files = images_dir.read_dir()
|
let image_files = images_dir.read_dir()
|
||||||
.expect("couldn't read images dir");
|
.expect("couldn't read image dir");
|
||||||
|
|
||||||
for file in image_files {
|
for file in image_files {
|
||||||
let file = file.unwrap();
|
let file = file.unwrap();
|
||||||
|
@ -163,6 +167,30 @@ impl Game {
|
||||||
println!("image found: {:?}", file.file_name());
|
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();
|
let mut game_config = path.clone();
|
||||||
game_config.push("game.toml");
|
game_config.push("game.toml");
|
||||||
let config = fs::read_to_string(game_config)
|
let config = fs::read_to_string(game_config)
|
||||||
|
@ -170,6 +198,6 @@ impl Game {
|
||||||
let config: Config = toml::from_str(&config)
|
let config: Config = toml::from_str(&config)
|
||||||
.expect("Couldn't parse game config");
|
.expect("Couldn't parse game config");
|
||||||
|
|
||||||
Ok(Game { config, images, palettes, music })
|
Ok(Game { config, images, tiles, palettes, music, entities })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue