diff --git a/src/setup.rs b/src/setup.rs index 14d616c..a1698a9 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -14,13 +14,20 @@ impl Plugin for SetupPlugin { /// Setup drawing our cards on the screen pub(crate) fn setup_cards(mut commands: Commands, deck: Res) { - Deck::iter_cards().for_each(|this_card| { + Deck::iter_cards().enumerate().for_each(|(i, this_card)| { let this = deck .cards .get(&this_card) .expect(format!("fech card sprite {:?}", this_card).as_str()) .clone(); - commands.spawn((this, this_card)); + // for a 9x9 grid we want x to wrap every 9 and y to increment every 9 + let x = i % 9; + let y = i / 9; + let l = 100.0; + let x_off = -50.0 * 7.0; + let y_off = -50.0 * 5.0; + let t = Transform::from_xyz(l * (x as f32) + x_off, l * (y as f32) + y_off, 0.0); + commands.spawn((this, this_card, t)); }); }