this is organized all wrong lol

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

@ -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),
},
));
}
}

@ -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<events::Play>,
mut commands: Commands,
mut board: ResMut<Board>,
throw_time: Res<Throwtime>,
) {
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));
}
}

Loading…
Cancel
Save