this is organized all wrong lol

main
Jordan Orelli 1 year ago
parent 06980c06fe
commit 5bd1d0bdae

@ -1,5 +1,6 @@
use bevy::prelude::*; use bevy::prelude::*;
use rand::Rng; use rand::Rng;
use std::time::Duration;
use tracing::info; use tracing::info;
use crate::{events::Events, play::Play, start_menu::StartMenu}; use crate::{events::Events, play::Play, start_menu::StartMenu};
@ -10,7 +11,13 @@ pub struct Game {}
impl Plugin for Game { impl Plugin for Game {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
info!("Building rps Plugin"); info!("Building rps Plugin");
app.add_plugins((Events {}, StartMenu {}, Play {})); app.add_plugins((
Events {},
StartMenu {},
Play {
throw_time: Duration::from_secs(5),
},
));
} }
} }

@ -41,7 +41,12 @@ impl Board {
} }
} }
pub struct Play {} pub struct Play {
pub throw_time: Duration,
}
#[derive(Resource)]
struct Throwtime(Duration);
#[derive(Component, Debug)] #[derive(Component, Debug)]
struct Action { struct Action {
@ -211,6 +216,7 @@ fn handle_play(
mut events: EventReader<events::Play>, mut events: EventReader<events::Play>,
mut commands: Commands, mut commands: Commands,
mut board: ResMut<Board>, mut board: ResMut<Board>,
throw_time: Res<Throwtime>,
) { ) {
if events.is_empty() { if events.is_empty() {
return; return;
@ -219,7 +225,7 @@ fn handle_play(
for e in events.iter() { for e in events.iter() {
info!("play event {e:?}"); 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(); board.clear();
info!("Starting countdown"); info!("Starting countdown");
@ -234,7 +240,6 @@ fn handle_play(
width: Val::Percent(100.0), width: Val::Percent(100.0),
..default() ..default()
}, },
border_color: Color::RED.into(),
background_color: Color::GRAY.into(), background_color: Color::GRAY.into(),
..default() ..default()
}, },
@ -307,5 +312,6 @@ impl Plugin for Play {
), ),
); );
app.insert_resource(Board::new()); app.insert_resource(Board::new());
app.insert_resource(Throwtime(self.throw_time));
} }
} }

Loading…
Cancel
Save