Fix player number in example game in the ecs_guide (#5098)

# Objective

- Small bug in the example game given in examples/ecs/ecs_guide

Currently, if there are 2 players in this example game, the function exclusive_player_system can add a player with the name "Player 2". However, the name should be "Player 3". This PR fixes this. I also add a message to inform that a new player has arrived in the mock game.

Co-authored-by: Dilyan Kostov <dilyanks@amazon.com>
This commit is contained in:
Dilyan 2022-06-26 13:58:56 +00:00
parent 056f12236e
commit 4f5f04041f

View file

@ -211,9 +211,10 @@ fn exclusive_player_system(world: &mut World) {
};
// Randomly add a new player
if should_add_player {
println!("Player {} has joined the game!", total_players + 1);
world.spawn().insert_bundle((
Player {
name: format!("Player {}", total_players),
name: format!("Player {}", total_players + 1),
},
Score { value: 0 },
));