diff --git a/src/game/dice.rs b/src/game/dice.rs index 707ef92..dd5daf2 100644 --- a/src/game/dice.rs +++ b/src/game/dice.rs @@ -72,28 +72,34 @@ fn init_dice( mut materials: ResMut>, mut commands: Commands ) { - commands.spawn(( - GameChoice::Dice, MenuState::Closed, - Die::new(["a", "b", "c", "d", "e", "f"]), - PickableBundle { ..default() }, - On::>::target_component_mut::(|m, transform| { - transform.translation.x += m.delta.x; - transform.translation.y -= m.delta.y; - }) - )).insert(Text2dBundle { - text: Text::from_section( - "", - TextStyle { - color: Color::BLACK, - font_size: 32.0, - ..default() - }, - ), - ..default() - }).insert(MaterialMesh2dBundle { - mesh: meshes.add(Rectangle { half_size: Vec2::splat(32.0) }).into(), - material: materials.add(Color::PINK), - ..default() + [ + ["a", "b", "c", "d", "e", "f"], + ["g", "h", "i", "j", "k", "l"], + ["m", "n", "o", "p", "q", "r"], + ].into_iter().enumerate().for_each(|(idx, set)| { + commands.spawn(( + GameChoice::Dice, MenuState::Closed, + Die::new(set), + PickableBundle { ..default() }, + On::>::target_component_mut::(|m, transform| { + transform.translation.x += m.delta.x; + transform.translation.y -= m.delta.y; + }) + )).insert(MaterialMesh2dBundle { + mesh: meshes.add(Rectangle { half_size: Vec2::splat(32.0) }).into(), + material: materials.add(Color::PINK), + ..default() + }).insert(Text2dBundle { + text: Text::from_section( + "", + TextStyle { + color: Color::BLACK, + font_size: 32.0, + ..default() + }, + ), + ..default() + }).insert(Transform::from_xyz(idx as f32 * 100.0, 100.0, 0.0)); }); }