diff --git a/Cargo.lock b/Cargo.lock index 52d2b4a..9fa73b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,7 @@ name = "game_test" version = "0.1.0" dependencies = [ "cat-box", + "play", "rand", "sdl2", ] @@ -55,6 +56,45 @@ version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" +[[package]] +name = "mpg123-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75c26239d85c1423091c109fcdabbcfaac868576dc018b0e959137217907610" +dependencies = [ + "bitflags", + "libc", + "pkg-config", +] + +[[package]] +name = "out123-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da977be7c4b44e2ad26be779aafc1761a89bd2ee6e363770bb71eb67a00d2e5" +dependencies = [ + "libc", + "mpg123-sys", + "pkg-config", +] + +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + +[[package]] +name = "play" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c570085654588139e9ea2f452fe7dcb78d576da4f1c04d58b98b32fc42744ff0" +dependencies = [ + "libc", + "mpg123-sys", + "out123-sys", +] + [[package]] name = "ppv-lite86" version = "0.2.16" diff --git a/Cargo.toml b/Cargo.toml index 7104a85..caab0fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,5 @@ edition = "2021" [dependencies] cat-box = "0.1.6" sdl2 = "0.35.2" -rand = "0.8.5" \ No newline at end of file +rand = "0.8.5" +play = "0.5.3" \ No newline at end of file diff --git a/HD - You are An Idiot Sound Effect-Sh9pSxSWhBk.f303.webm b/HD - You are An Idiot Sound Effect-Sh9pSxSWhBk.f303.webm new file mode 100644 index 0000000..03d6c60 Binary files /dev/null and b/HD - You are An Idiot Sound Effect-Sh9pSxSWhBk.f303.webm differ diff --git a/sound.mp3 b/sound.mp3 new file mode 100644 index 0000000..f7af101 Binary files /dev/null and b/sound.mp3 differ diff --git a/sound.ogg b/sound.ogg new file mode 100644 index 0000000..8f6d780 Binary files /dev/null and b/sound.ogg differ diff --git a/src/balls.rs b/src/balls.rs deleted file mode 100644 index b66dffb..0000000 --- a/src/balls.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::fs::File; -use std::io::BufReader; -use rodio::{Decoder, OutputStream, source::Source}; - - - pub fn play() { - let (_stream, stream_handle) = OutputStream::try_default().unwrap(); -// Load a sound from a file, using a path relative to Cargo.toml - let file = BufReader::new(File::open("sound.ogg").unwrap()); -// Decode that sound file into a source - let source = Decoder::new(file).unwrap(); -// Play the sound directly on the device - stream_handle.play_raw(source.convert_samples()); - -// The sound plays in a separate audio thread, -// so we need to keep the main thread alive while it's playing. - std::thread::sleep(std::time::Duration::from_secs(5)); - } diff --git a/src/main.rs b/src/main.rs index fdf36dd..5acf8e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use cat_box::{draw_text, Game, Sprite}; -use std::{thread, time, fs::File, io::BufReader}; -pub mod balls; +use std::{thread, time, fs::File, io::BufReader, process::Command}; +use play; fn main() { let game = Game::new("catbox testing", 500, 500); @@ -10,7 +10,7 @@ fn main() { let mut i2 = 0u8; let sleep = thread::sleep; - + game.run(|ctx| { let mut s = Sprite::new(sprite1, 250, 150).unwrap(); @@ -42,9 +42,15 @@ fn main() { colour: (i2,i2,i2), } ).unwrap(); - + s.draw(ctx).unwrap(); s1.draw(ctx).unwrap(); s2.draw(ctx).unwrap(); + Command::new("play") + .arg("./sound.mp3") + .output() + .expect("fucked up"); }).unwrap(); + + } \ No newline at end of file diff --git a/you are an idiot sound effect.mp4 b/you are an idiot sound effect.mp4 new file mode 100644 index 0000000..6cd6ae4 Binary files /dev/null and b/you are an idiot sound effect.mp4 differ