diff --git a/crates/border-wars/src/lib.rs b/crates/border-wars/src/lib.rs index f6e9173..a4acdb8 100644 --- a/crates/border-wars/src/lib.rs +++ b/crates/border-wars/src/lib.rs @@ -19,14 +19,3 @@ pub enum CurrentScene { /// When we play this wonderful game. Game, } - -/// Calculates the ui_scale.0 depending on the size of the main node -/// in order to make the screen responsive -pub fn change_scaling(mut ui_scale: ResMut, window: Query<&Window>) { - let window = window.single(); - let (a, b) = ( - window.resolution.width() / 1280., - window.resolution.height() / 720., - ); - ui_scale.0 = if a < b { a } else { b } as f64 -} diff --git a/crates/border-wars/src/responsive_scale.rs b/crates/border-wars/src/responsive_scale.rs new file mode 100644 index 0000000..89681e5 --- /dev/null +++ b/crates/border-wars/src/responsive_scale.rs @@ -0,0 +1,13 @@ +const DEFAULT_WIDTH = 1280. +const DEFAULT_HEIGHT = 720. + +/// Calculates the ui_scale.0 depending on the size of the main node +/// in order to make the screen responsive +pub fn change_scaling(mut ui_scale: ResMut, window: Query<&Window>) { + let window = window.single(); + let (a, b) = ( + window.resolution.width() / DEFAULT_WIDTH, + window.resolution.height() / DEFAULT_HEIGHT, + ); + ui_scale.0 = if a < b { a } else { b } as f64 +} \ No newline at end of file