Skip to content

Commit 4f5f040

Browse files
dilyankostovDilyan Kostov
and
Dilyan Kostov
committed
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 <[email protected]>
1 parent 056f122 commit 4f5f040

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/ecs/ecs_guide.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,10 @@ fn exclusive_player_system(world: &mut World) {
211211
};
212212
// Randomly add a new player
213213
if should_add_player {
214+
println!("Player {} has joined the game!", total_players + 1);
214215
world.spawn().insert_bundle((
215216
Player {
216-
name: format!("Player {}", total_players),
217+
name: format!("Player {}", total_players + 1),
217218
},
218219
Score { value: 0 },
219220
));

0 commit comments

Comments
 (0)