Move map and sound stuff to resources module

This commit is contained in:
Alex Page 2022-01-27 02:04:18 -05:00
parent a8500b96d2
commit 6ce6470236
7 changed files with 23 additions and 14 deletions

View file

@ -2,11 +2,8 @@
pub mod components; pub mod components;
pub mod constants; pub mod constants;
mod map;
pub mod resources; pub mod resources;
mod sidebar; mod sidebar;
mod sound;
mod sound_effects;
mod state; mod state;
pub mod systems; pub mod systems;
pub mod vga_color; pub mod vga_color;
@ -16,10 +13,8 @@ use components::{
monster::{color_for_kind, glyphs_for_kind, ticks_for_kind, MonsterKind}, monster::{color_for_kind, glyphs_for_kind, ticks_for_kind, MonsterKind},
Monster, Player, Position, Renderable, Monster, Player, Position, Renderable,
}; };
use map::{Map, TileType}; use resources::map::TileType;
use resources::{Clock, LevelNumber, ShowDebugInfo, Stats}; use resources::{Clock, LevelNumber, Map, ShowDebugInfo, SoundEffects, SoundSystem, Stats};
use sound::SoundSystem;
use sound_effects::SoundEffects;
use specs::prelude::*; use specs::prelude::*;
use state::State; use state::State;
use std::time::Instant; use std::time::Instant;

View file

@ -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 crate::constants::CLOCK_PERIOD;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};

View file

@ -2,7 +2,9 @@ use std::{array, iter, time::Duration};
use bracket_lib::random::RandomNumberGenerator; 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 struct SoundEffects {
pub startup: SoundEffectSamples, pub startup: SoundEffectSamples,

View file

@ -34,6 +34,12 @@ pub struct SoundSystem {
_stream: Stream, _stream: Stream,
} }
impl Default for SoundSystem {
fn default() -> Self {
Self::new()
}
}
impl SoundSystem { impl SoundSystem {
pub fn new() -> Self { pub fn new() -> Self {
let host = cpal::default_host(); let host = cpal::default_host();

View file

@ -2,10 +2,8 @@ use std::time::{Duration, Instant};
use crate::components::monster::damage_for_kind; use crate::components::monster::damage_for_kind;
use crate::components::{Monster, Player, Position, Renderable}; use crate::components::{Monster, Player, Position, Renderable};
use crate::map::{Map, TileType}; use crate::resources::map::TileType;
use crate::resources::{Clock, ShowDebugInfo, Stats}; use crate::resources::{Clock, Map, ShowDebugInfo, SoundEffects, SoundSystem, Stats};
use crate::sound::SoundSystem;
use crate::sound_effects::SoundEffects;
use crate::systems::MonsterMotion; use crate::systems::MonsterMotion;
use crate::{constants::*, sidebar}; use crate::{constants::*, sidebar};
use bracket_lib::prelude::*; use bracket_lib::prelude::*;

View file

@ -3,8 +3,8 @@ use crate::{
monster::{self, damage_for_kind, ticks_for_kind}, monster::{self, damage_for_kind, ticks_for_kind},
Monster, Position, Renderable, Monster, Position, Renderable,
}, },
map::{Map, TileType}, resources::map::TileType,
resources::{Clock, Stats}, resources::{Clock, Map, Stats},
}; };
use bracket_lib::{prelude::*, random::RandomNumberGenerator}; use bracket_lib::{prelude::*, random::RandomNumberGenerator};
use specs::prelude::*; use specs::prelude::*;