Skip to content

Commit

Permalink
Use constants instead
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Jan 8, 2022
1 parent 549ae13 commit 7b2cbc9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions examples/window/expanding_window.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use bevy::prelude::*;

const MAX_WIDTH: f32 = 400.;
const MAX_HEIGHT: f32 = 400.;

fn main() {
App::new()
.insert_resource(WindowDescriptor {
width: 200.,
height: 200.,
width: MAX_WIDTH,
height: MAX_HEIGHT,
scale_factor_override: Some(1.),
..Default::default()
})
Expand Down Expand Up @@ -41,13 +44,13 @@ fn change_window_size(mut windows: ResMut<Windows>, mut phase: ResMut<Phase>) {
primary.set_resolution((width - 4.).max(0.0), height)
}
Phase::ExpandingY => {
if height >= 200. {
if height >= MAX_HEIGHT {
*phase = ExpandingX;
}
primary.set_resolution(width, height + 4.)
}
Phase::ExpandingX => {
if width >= 200. {
if width >= MAX_WIDTH {
*phase = ContractingY;
}
primary.set_resolution(width + 4., height)
Expand Down

0 comments on commit 7b2cbc9

Please sign in to comment.