Skip to content

Commit d43b5d3

Browse files
committed
Use constants instead
Actually add a camera
1 parent bbb2c90 commit d43b5d3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

examples/window/expanding_window.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
use bevy::prelude::*;
22

3+
const MAX_WIDTH: f32 = 400.;
4+
const MAX_HEIGHT: f32 = 400.;
5+
36
fn main() {
47
App::new()
58
.insert_resource(WindowDescriptor {
6-
width: 200.,
7-
height: 200.,
9+
width: MAX_WIDTH,
10+
height: MAX_HEIGHT,
811
scale_factor_override: Some(1.),
912
..Default::default()
1013
})
1114
.add_plugins(DefaultPlugins)
1215
.insert_resource(Phase::ContractingY)
1316
.add_system(change_window_size)
17+
.add_startup_system(setup)
1418
.run();
1519
}
1620

21+
fn setup(mut commands: Commands) {
22+
commands.spawn_bundle(OrthographicCameraBundle::new_3d());
23+
}
24+
1725
enum Phase {
1826
ContractingY,
1927
ContractingX,
@@ -41,13 +49,13 @@ fn change_window_size(mut windows: ResMut<Windows>, mut phase: ResMut<Phase>) {
4149
primary.set_resolution((width - 4.).max(0.0), height)
4250
}
4351
Phase::ExpandingY => {
44-
if height >= 200. {
52+
if height >= MAX_HEIGHT {
4553
*phase = ExpandingX;
4654
}
4755
primary.set_resolution(width, height + 4.)
4856
}
4957
Phase::ExpandingX => {
50-
if width >= 200. {
58+
if width >= MAX_WIDTH {
5159
*phase = ContractingY;
5260
}
5361
primary.set_resolution(width + 4., height)

0 commit comments

Comments
 (0)