mirror of
https://github.com/bevyengine/bevy
synced 2024-11-29 08:00:20 +00:00
alien-cake-addict example: ensure the cake doesn't spawn on the player (#1713)
fixes #1707 In the game, it makes sense to never spawn the cake on the player.
This commit is contained in:
parent
2dd2e5e9fe
commit
94f45586ce
1 changed files with 9 additions and 2 deletions
|
@ -307,8 +307,15 @@ fn spawn_bonus(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure bonus doesn't spawn on the player
|
||||||
|
loop {
|
||||||
game.bonus.i = rand::thread_rng().gen_range(0..BOARD_SIZE_I);
|
game.bonus.i = rand::thread_rng().gen_range(0..BOARD_SIZE_I);
|
||||||
game.bonus.j = rand::thread_rng().gen_range(0..BOARD_SIZE_J);
|
game.bonus.j = rand::thread_rng().gen_range(0..BOARD_SIZE_J);
|
||||||
|
if game.bonus.i != game.player.i || game.bonus.j != game.player.j {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
game.bonus.entity = commands
|
game.bonus.entity = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
Transform {
|
Transform {
|
||||||
|
|
Loading…
Reference in a new issue