Skip to content

Commit

Permalink
Use constants instead
Browse files Browse the repository at this point in the history
Actually add a camera
  • Loading branch information
DJMcNab committed Mar 26, 2022
1 parent b236cd3 commit 4ed569b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions examples/window/expanding_window.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
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()
})
.add_plugins(DefaultPlugins)
.insert_resource(Phase::ContractingY)
.add_system(change_window_size)
.add_startup_system(setup)
.run();
}

fn setup(mut commands: Commands) {
commands.spawn_bundle(OrthographicCameraBundle::new_3d());
}

enum Phase {
ContractingY,
ContractingX,
Expand Down Expand Up @@ -41,13 +49,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 4ed569b

Please sign in to comment.