diff --git a/src/game.rs b/src/game.rs index 2f74f10..8ee69ef 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,5 +1,6 @@ use bevy::prelude::*; use rand::Rng; +use std::time::Duration; use tracing::info; use crate::{events::Events, play::Play, start_menu::StartMenu}; @@ -10,7 +11,13 @@ pub struct Game {} impl Plugin for Game { fn build(&self, app: &mut App) { info!("Building rps Plugin"); - app.add_plugins((Events {}, StartMenu {}, Play {})); + app.add_plugins(( + Events {}, + StartMenu {}, + Play { + throw_time: Duration::from_secs(5), + }, + )); } } diff --git a/src/play.rs b/src/play.rs index 543a6b5..a0cc810 100644 --- a/src/play.rs +++ b/src/play.rs @@ -41,7 +41,12 @@ impl Board { } } -pub struct Play {} +pub struct Play { + pub throw_time: Duration, +} + +#[derive(Resource)] +struct Throwtime(Duration); #[derive(Component, Debug)] struct Action { @@ -211,6 +216,7 @@ fn handle_play( mut events: EventReader, mut commands: Commands, mut board: ResMut, + throw_time: Res, ) { if events.is_empty() { return; @@ -219,7 +225,7 @@ fn handle_play( for e in events.iter() { info!("play event {e:?}"); } - board.phase = Phase::Countdown(Timer::new(Duration::from_millis(3000), TimerMode::Once)); + board.phase = Phase::Countdown(Timer::new(throw_time.0, TimerMode::Once)); board.clear(); info!("Starting countdown"); @@ -234,7 +240,6 @@ fn handle_play( width: Val::Percent(100.0), ..default() }, - border_color: Color::RED.into(), background_color: Color::GRAY.into(), ..default() }, @@ -307,5 +312,6 @@ impl Plugin for Play { ), ); app.insert_resource(Board::new()); + app.insert_resource(Throwtime(self.throw_time)); } }