diff --git a/src/main.rs b/src/main.rs index 17ebc40..ffc6cd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,11 +2,8 @@ pub mod components; pub mod constants; -mod map; pub mod resources; mod sidebar; -mod sound; -mod sound_effects; mod state; pub mod systems; pub mod vga_color; @@ -16,10 +13,8 @@ use components::{ monster::{color_for_kind, glyphs_for_kind, ticks_for_kind, MonsterKind}, Monster, Player, Position, Renderable, }; -use map::{Map, TileType}; -use resources::{Clock, LevelNumber, ShowDebugInfo, Stats}; -use sound::SoundSystem; -use sound_effects::SoundEffects; +use resources::map::TileType; +use resources::{Clock, LevelNumber, Map, ShowDebugInfo, SoundEffects, SoundSystem, Stats}; use specs::prelude::*; use state::State; use std::time::Instant; diff --git a/src/map.rs b/src/resources/map.rs similarity index 100% rename from src/map.rs rename to src/resources/map.rs diff --git a/src/resources/mod.rs b/src/resources/mod.rs index 59ff897..bc444d3 100644 --- a/src/resources/mod.rs +++ b/src/resources/mod.rs @@ -1,3 +1,11 @@ +pub mod map; +pub mod sound_effects; +pub mod sound_system; + +pub use map::Map; +pub use sound_effects::SoundEffects; +pub use sound_system::SoundSystem; + use crate::constants::CLOCK_PERIOD; use std::time::{Duration, Instant}; diff --git a/src/sound_effects.rs b/src/resources/sound_effects.rs similarity index 97% rename from src/sound_effects.rs rename to src/resources/sound_effects.rs index d096880..d704ee2 100644 --- a/src/sound_effects.rs +++ b/src/resources/sound_effects.rs @@ -2,7 +2,9 @@ use std::{array, iter, time::Duration}; use bracket_lib::random::RandomNumberGenerator; -use crate::sound::{Sound, SoundEffect, SoundEffectSamples, SoundSystem, SoundType}; +use crate::resources::sound_system::{ + Sound, SoundEffect, SoundEffectSamples, SoundSystem, SoundType, +}; pub struct SoundEffects { pub startup: SoundEffectSamples, diff --git a/src/sound.rs b/src/resources/sound_system.rs similarity index 98% rename from src/sound.rs rename to src/resources/sound_system.rs index 35c8497..73cf1b8 100644 --- a/src/sound.rs +++ b/src/resources/sound_system.rs @@ -34,6 +34,12 @@ pub struct SoundSystem { _stream: Stream, } +impl Default for SoundSystem { + fn default() -> Self { + Self::new() + } +} + impl SoundSystem { pub fn new() -> Self { let host = cpal::default_host(); diff --git a/src/state.rs b/src/state.rs index 94d385c..dc26c9c 100644 --- a/src/state.rs +++ b/src/state.rs @@ -2,10 +2,8 @@ use std::time::{Duration, Instant}; use crate::components::monster::damage_for_kind; use crate::components::{Monster, Player, Position, Renderable}; -use crate::map::{Map, TileType}; -use crate::resources::{Clock, ShowDebugInfo, Stats}; -use crate::sound::SoundSystem; -use crate::sound_effects::SoundEffects; +use crate::resources::map::TileType; +use crate::resources::{Clock, Map, ShowDebugInfo, SoundEffects, SoundSystem, Stats}; use crate::systems::MonsterMotion; use crate::{constants::*, sidebar}; use bracket_lib::prelude::*; diff --git a/src/systems/monster_motion.rs b/src/systems/monster_motion.rs index ed25367..52d2f2f 100644 --- a/src/systems/monster_motion.rs +++ b/src/systems/monster_motion.rs @@ -3,8 +3,8 @@ use crate::{ monster::{self, damage_for_kind, ticks_for_kind}, Monster, Position, Renderable, }, - map::{Map, TileType}, - resources::{Clock, Stats}, + resources::map::TileType, + resources::{Clock, Map, Stats}, }; use bracket_lib::{prelude::*, random::RandomNumberGenerator}; use specs::prelude::*;