|
|
|
|
@ -12,7 +12,7 @@ use fighter::*;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
App::new()
|
|
|
|
|
.add_plugins((DefaultPlugins, BlocksPlugin, FighterPlugin))
|
|
|
|
|
.add_plugins((DefaultPlugins, BlocksPlugin, FighterPlugin, DebugPlugin))
|
|
|
|
|
.init_state::<Loading>()
|
|
|
|
|
.init_state::<Debugger>()
|
|
|
|
|
.init_state::<GameState>()
|
|
|
|
|
@ -42,14 +42,6 @@ enum Loading {
|
|
|
|
|
Idle,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Tracks if the game is in debug mode
|
|
|
|
|
#[derive(States, Default, Clone, Eq, Debug, PartialEq, Hash)]
|
|
|
|
|
enum Debugger {
|
|
|
|
|
#[default]
|
|
|
|
|
Off,
|
|
|
|
|
On,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Tracks what state the main game loop is in
|
|
|
|
|
#[derive(States, Default, Clone, Eq, Debug, PartialEq, Hash)]
|
|
|
|
|
enum GameState {
|
|
|
|
|
@ -71,6 +63,12 @@ struct SetupChecklist {
|
|
|
|
|
spawn_shape: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl SetupChecklist {
|
|
|
|
|
fn done(&self) -> bool {
|
|
|
|
|
self.spawn_shape
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Sends the game into Loading::Active if assets are added to the AllAssets list
|
|
|
|
|
fn loading_check(mut next: ResMut<NextState<Loading>>, all_assets: Res<AllAssets>) {
|
|
|
|
|
debug_assert!(all_assets.is_changed());
|
|
|
|
|
@ -102,6 +100,7 @@ fn setup_game(curr: Res<State<GameState>>, mut next: ResMut<NextState<GameState>
|
|
|
|
|
next.set(GameState::Setup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Wait until all checklist items are complete
|
|
|
|
|
fn setup_wait(
|
|
|
|
|
curr: Res<State<GameState>>,
|
|
|
|
|
mut next: ResMut<NextState<GameState>>,
|
|
|
|
|
@ -110,7 +109,7 @@ fn setup_wait(
|
|
|
|
|
debug_assert!(*curr.get() == GameState::Setup);
|
|
|
|
|
|
|
|
|
|
// If all checks pass, move on to the run state
|
|
|
|
|
if checklist.spawn_shape {
|
|
|
|
|
if checklist.done() {
|
|
|
|
|
next.set(GameState::Run);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|