1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-09-27 20:48:54 +00:00
doukutsu-rs/src/sound/mod.rs

34 lines
924 B
Rust
Raw Normal View History

2020-08-19 19:11:32 +00:00
use crate::ggez::{Context, GameResult};
2020-08-18 16:46:07 +00:00
pub mod pixtone;
pub struct SoundManager {
2020-08-19 19:11:32 +00:00
intro: Vec<u8>,
sloop: Vec<u8>,
2020-08-18 16:46:07 +00:00
}
2020-08-19 19:11:32 +00:00
//unsafe impl Send for SoundManager {}
2020-08-18 16:46:07 +00:00
impl SoundManager {
2020-08-19 19:11:32 +00:00
pub fn new(ctx: &mut Context) -> SoundManager {
2020-08-18 16:46:07 +00:00
SoundManager {
2020-08-19 19:11:32 +00:00
intro: Vec::new(),
sloop: Vec::new(),
2020-08-18 16:46:07 +00:00
}
}
pub fn play_song(&mut self, ctx: &mut Context) -> GameResult {
2020-08-19 19:11:32 +00:00
/*self.intro.clear();
self.sloop.clear();
ggez::filesystem::open(ctx, "/base/Ogg11/curly_intro.ogg")?.read_to_end(&mut self.intro)?;
ggez::filesystem::open(ctx, "/base/Ogg11/curly_loop.ogg")?.read_to_end(&mut self.sloop)?;
2020-08-18 16:46:07 +00:00
2020-08-19 19:11:32 +00:00
let sink = Sink::new(ctx.audio_context.device());
sink.append(rodio::Decoder::new(Cursor::new(self.intro.clone()))?);
sink.append(rodio::Decoder::new(Cursor::new(self.sloop.clone()))?);
2020-08-19 00:55:21 +00:00
sink.detach();*/
2020-08-18 16:46:07 +00:00
Ok(())
}
}