fn size_scaling(windows: Query<&Window>, mut sprites: Query<(&Size, &mut Transform)>) {
let window = windows.single();
for (sz, mut transform) in sprites.iter_mut() {
transform.scale = Vec3::new(
sz.0 / GRID_SIZE as f32 * window.width(),
sz.0 / GRID_SIZE as f32 * window.height(),
1.,
);
}
}
fn postion_translation(windows: Query<&Window>, mut sprites: Query<(&Position, &mut Transform)>) {
fn convert(pos: f32, window_size: f32) -> f32 {
let tile_size_in_px = window_size / GRID_SIZE as f32;
pos / GRID_SIZE as f32 * window_size - (window_size / 2.) + (tile_size_in_px / 2.)
}
let window = windows.single();
for (pos, mut transform) in sprites.iter_mut() {
transform.translation = Vec3::new(
convert(pos.x as f32, window.width()),
convert(pos.y as f32, window.height()),
0.,
)
}
}