From 2d788021535c155344b807cc91856a862d6f5168 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Wed, 4 Dec 2024 22:58:07 -0800 Subject: [PATCH] printing all cards fitting roughly on screen for debug --- src/setup.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/setup.rs b/src/setup.rs index a1698a9..60df47b 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -14,20 +14,26 @@ impl Plugin for SetupPlugin { /// Setup drawing our cards on the screen pub(crate) fn setup_cards(mut commands: Commands, deck: Res) { + let size = 75.0; 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(); + let new_this = Sprite { + custom_size: Some(Vec2::new(size, size)), + ..this + }; // for a 9x9 grid we want x to wrap every 9 and y to increment every 9 + // TODO: Determine based on screen size what this offset and scaling should be 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 l = size; + let x_off = -(size / 2.0) * 9.0; + let y_off = -(size / 2.0) * 8.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)); + commands.spawn((new_this, this_card, t)); }); }