Add music

This commit is contained in:
crumblingstatue 2023-04-03 23:36:45 +02:00
parent 20409e3ee2
commit 69b022ea02
3 changed files with 6 additions and 2 deletions

BIN
res/music.ogg Normal file

Binary file not shown.

View file

@ -32,11 +32,13 @@ impl App {
pub fn new() -> anyhow::Result<Self> { pub fn new() -> anyhow::Result<Self> {
let rw = graphics::make_window(); let rw = graphics::make_window();
let sf_egui = SfEgui::new(&rw); let sf_egui = SfEgui::new(&rw);
let mut res = Res::load()?;
res.music.play();
Ok(Self { Ok(Self {
rw, rw,
should_quit: false, should_quit: false,
game: GameState::default(), game: GameState::default(),
res: Res::load()?, res,
sf_egui, sf_egui,
input: Input::default(), input: Input::default(),
debug: DebugState::default(), debug: DebugState::default(),

View file

@ -1,13 +1,15 @@
use sfml::{graphics::Texture, SfBox}; use sfml::{audio::Music, graphics::Texture, SfBox};
pub struct Res { pub struct Res {
pub tile_atlas: SfBox<Texture>, pub tile_atlas: SfBox<Texture>,
pub music: Music<'static>,
} }
impl Res { impl Res {
pub fn load() -> anyhow::Result<Self> { pub fn load() -> anyhow::Result<Self> {
Ok(Self { Ok(Self {
tile_atlas: Texture::from_file("res/tiles.png")?, tile_atlas: Texture::from_file("res/tiles.png")?,
music: Music::from_file("res/music.ogg").unwrap(),
}) })
} }
} }