diff --git a/src/game/mod.rs b/src/game/mod.rs index 42af5d4..eccc01e 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -76,12 +76,18 @@ impl Game { let dir = path.parent().unwrap(); let song = Sound::create(dir.join(&self.beatmap.inner.audio_filename))?; - song.set_position(65.0)?; self.song = Some(song); Ok(()) } + pub fn jump_to_time(&mut self, time: f64) -> Result<()> { + if let Some(song) = &self.song { + song.set_position(time)?; + } + Ok(()) + } + pub fn toggle_playing(&mut self) { if self.is_playing { self.is_playing = false; diff --git a/src/main.rs b/src/main.rs index 2c4ca70..60411e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,9 @@ use crate::game::Game; #[derive(StructOpt)] struct Opt { + #[structopt(short = "s")] + start_time: Option, + path: Option, /// Verbose mode (-v, -vv, -vvv, etc) @@ -53,6 +56,10 @@ fn main() -> Result<()> { game.load_beatmap(path)?; } + if let Some(start_time) = opt.start_time { + game.jump_to_time(start_time)?; + } + event::run(&mut ctx, &mut event_loop, &mut game)?; Ok(())