initial sound
This commit is contained in:
parent
01b2f0bfc1
commit
7d26d56132
40
Cargo.lock
generated
40
Cargo.lock
generated
|
@ -28,6 +28,7 @@ name = "game_test"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cat-box",
|
"cat-box",
|
||||||
|
"play",
|
||||||
"rand",
|
"rand",
|
||||||
"sdl2",
|
"sdl2",
|
||||||
]
|
]
|
||||||
|
@ -55,6 +56,45 @@ version = "0.2.125"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
|
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]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
|
|
@ -8,4 +8,5 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cat-box = "0.1.6"
|
cat-box = "0.1.6"
|
||||||
sdl2 = "0.35.2"
|
sdl2 = "0.35.2"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
play = "0.5.3"
|
BIN
HD - You are An Idiot Sound Effect-Sh9pSxSWhBk.f303.webm
Normal file
BIN
HD - You are An Idiot Sound Effect-Sh9pSxSWhBk.f303.webm
Normal file
Binary file not shown.
18
src/balls.rs
18
src/balls.rs
|
@ -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));
|
|
||||||
}
|
|
14
src/main.rs
14
src/main.rs
|
@ -1,6 +1,6 @@
|
||||||
use cat_box::{draw_text, Game, Sprite};
|
use cat_box::{draw_text, Game, Sprite};
|
||||||
use std::{thread, time, fs::File, io::BufReader};
|
use std::{thread, time, fs::File, io::BufReader, process::Command};
|
||||||
pub mod balls;
|
use play;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let game = Game::new("catbox testing", 500, 500);
|
let game = Game::new("catbox testing", 500, 500);
|
||||||
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
let mut i2 = 0u8;
|
let mut i2 = 0u8;
|
||||||
|
|
||||||
let sleep = thread::sleep;
|
let sleep = thread::sleep;
|
||||||
|
|
||||||
game.run(|ctx| {
|
game.run(|ctx| {
|
||||||
|
|
||||||
let mut s = Sprite::new(sprite1, 250, 150).unwrap();
|
let mut s = Sprite::new(sprite1, 250, 150).unwrap();
|
||||||
|
@ -42,9 +42,15 @@ fn main() {
|
||||||
colour: (i2,i2,i2),
|
colour: (i2,i2,i2),
|
||||||
}
|
}
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
s.draw(ctx).unwrap();
|
s.draw(ctx).unwrap();
|
||||||
s1.draw(ctx).unwrap();
|
s1.draw(ctx).unwrap();
|
||||||
s2.draw(ctx).unwrap();
|
s2.draw(ctx).unwrap();
|
||||||
|
Command::new("play")
|
||||||
|
.arg("./sound.mp3")
|
||||||
|
.output()
|
||||||
|
.expect("fucked up");
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
BIN
you are an idiot sound effect.mp4
Normal file
BIN
you are an idiot sound effect.mp4
Normal file
Binary file not shown.
Loading…
Reference in a new issue