/// Displays the score when the game is over.
Displays the score when the game is over.
Displays the score when the game is over .
fn game_over(mut commands: Commands, game: Res<game::Game>, game_materials: Res<GameMaterials>) {
    commands
        .spawn_bundle(NodeBundle {
            style: Style {
                margin: Rect::all(Val::Auto),
                justify_content: JustifyContent::Center,
                align_items: AlignItems::Center,
                ..Default::default()
            },
            material: game_materials.transparent.clone(),
            ..Default::default()
        })
        .insert(GameOver)
        .with_children(|parent| {
            parent.spawn_bundle(TextBundle {
                text: Text::with_section(
                    format!(
                        "Game over. {}",
                        match game.state() {
                            game::GameState::Won => "You won!",
                            game::GameState::Lost => "You lost!",
                            _ => unreachable!(),
                        }
                    ),
                    TextStyle {
                        font: game_materials.notification_font.clone(),
                        font_size: 80.0,
                        color: Color::BLACK,
                    },
                    Default::default(),
                ),
                ..Default::default()
            });
        });
}
fn game_over ( mut commands : Commands , game : Res < game :: Game > , game_materials : Res < GameMaterials > ) { commands . spawn_bundle ( NodeBundle { style : Style { margin : Rect :: all ( Val :: Auto ) , justify_content : JustifyContent :: Center , align_items : AlignItems :: Center , .. Default :: default ( ) } , material : game_materials . transparent . clone ( ) , .. Default :: default ( ) } ) . insert ( GameOver ) . with_children ( | parent | { parent . spawn_bundle ( TextBundle { text : Text :: with_section ( format ! ( " " match game state ( ) { game GameState Won " " game GameState Lost " " unreachable ( ) } ) , TextStyle { font : game_materials . notification_font . clone ( ) , font_size : 80.0 , color : Color :: BLACK , } , Default :: default ( ) , ) , .. Default :: default ( ) } ) ; } ) ; }
Displays the score when the game is over.
Displays the score when the game is over .
commands
Commands
game
Res<game::Game>
game_materials
Res<GameMaterials>