mirror of
https://github.com/lisk77/comet.git
synced 2025-12-12 09:08:49 +00:00
feat: added comet_sound to cargo toml and added with_audio to the builder pattern
This commit is contained in:
parent
9777c4b6b4
commit
bc9ea50264
3 changed files with 12 additions and 3 deletions
|
|
@ -16,6 +16,7 @@ comet_ecs = { path = "./crates/comet_ecs", workspace = true }
|
|||
comet_input = { path = "./crates/comet_input", workspace = true }
|
||||
comet_log = { path = "./crates/comet_log", workspace = true }
|
||||
comet_structs = { path = "./crates/comet_structs", workspace = true }
|
||||
comet_sound = { path = "./crates/comet_sound", workspace = true }
|
||||
|
||||
cfg-if = "1"
|
||||
anyhow = "1.0"
|
||||
|
|
@ -62,4 +63,5 @@ comet_resources = { path = "./crates/comet_resources", workspace = true }
|
|||
comet_ecs = { path = "./crates/comet_ecs", workspace = true }
|
||||
comet_input = { path = "./crates/comet_input", workspace = true }
|
||||
comet_log = { path = "./crates/comet_log", workspace = true }
|
||||
comet_structs = { path = "./crates/comet_structs", workspace = true }
|
||||
comet_structs = { path = "./crates/comet_structs", workspace = true }
|
||||
comet_sound = { path = "./crates/comet_sound", workspace = true }
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@ impl App {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_audio(mut self, audio_system: Box<dyn Audio>) -> Self {
|
||||
self.audio = audio_system;
|
||||
self
|
||||
}
|
||||
|
||||
fn load_icon(path: &std::path::Path) -> Option<Icon> {
|
||||
let image = match image::open(path) {
|
||||
Ok(image) => image,
|
||||
|
|
@ -387,8 +392,7 @@ impl App {
|
|||
match renderer.render() {
|
||||
Ok(_) => {}
|
||||
Err(
|
||||
wgpu::SurfaceError::Lost
|
||||
| wgpu::SurfaceError::Outdated,
|
||||
wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated,
|
||||
) => {
|
||||
let size = renderer.size();
|
||||
renderer.resize(size);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use comet::prelude::*;
|
||||
use comet_sound::Audio;
|
||||
|
||||
fn setup(app: &mut App, _renderer: &mut Renderer2D) {
|
||||
app.load_audio("startup", "res/sounds/hit.ogg");
|
||||
|
|
@ -19,5 +20,7 @@ fn update(app: &mut App, renderer: &mut Renderer2D, dt: f32) {
|
|||
fn main() {
|
||||
App::new()
|
||||
.with_title("Comet Audio Example")
|
||||
// This can be used to add your own sound engine to the engine
|
||||
.with_audio(Box::new(comet_sound::KiraAudio::new())) // to
|
||||
.run::<Renderer2D>(setup, update);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue