Skip to content

Commit

Permalink
Upgrade to Bevy 0.15 (#8)
Browse files Browse the repository at this point in the history
* Upgrade to Bevy 0.15

* Use released Bevy 0.15

* Add missing bevy_window feature
  • Loading branch information
rparrett authored Nov 30, 2024
1 parent 8fc7919 commit 7079f76
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 34 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ webgl2 = ["bevy/webgl2"]
webgpu = ["bevy/webgpu"]

[dependencies.bevy]
version = "0.14"
version = "0.15"
default-features = false
features = ["bevy_render"]

[dependencies]
crossbeam-channel = "0.5.0"

[dev-dependencies.bevy]
version = "0.14"
version = "0.15"
default-features = false
features = [
"android_shared_stdcxx",
Expand All @@ -38,6 +38,7 @@ features = [
"bevy_state",
"bevy_ui",
"bevy_winit",
"bevy_window",
"default_font",
"hdr",
"multi_threaded",
Expand Down
52 changes: 20 additions & 32 deletions examples/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ enum GameState {
Ready,
}

#[derive(Component)]
struct LoadingOnly;

// This value should be found experimentally by logging `PipelinesReady` in your app
// during normal use and noting the maximum value.
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -28,6 +25,7 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugins(PipelinesReadyPlugin)
.init_state::<GameState>()
.enable_state_scoped_entities::<GameState>()
.add_systems(Startup, setup_loading_screen)
.add_systems(Update, print.run_if(resource_changed::<PipelinesReady>))
.add_systems(
Expand All @@ -36,7 +34,6 @@ fn main() {
.run_if(in_state(GameState::Loading))
.run_if(resource_changed::<PipelinesReady>),
)
.add_systems(OnExit(GameState::Loading), cleanup::<LoadingOnly>)
.run();
}

Expand All @@ -48,37 +45,34 @@ fn setup_loading_screen(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
TextBundle::from_section("Pipelines loading...".to_string(), TextStyle::default()),
LoadingOnly,
Text::new("Pipelines loading...".to_string()),
StateScoped(GameState::Loading),
));

commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
intensity: 1_000_000.,
..default()
},
transform: Transform::from_xyz(3.0, 6.0, 5.0),
..default()
});
Transform::from_xyz(3.0, 6.0, 5.0),
));

commands.spawn(PbrBundle {
mesh: meshes.add(Cylinder::default()),
material: materials.add(Color::from(bevy::color::palettes::tailwind::PINK_500)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cylinder::default())),
MeshMaterial3d(materials.add(Color::from(bevy::color::palettes::tailwind::PINK_500))),
));

commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(10.0, 10.0)),
material: materials.add(Color::from(Srgba::gray(0.6))),
transform: Transform::from_xyz(0., -0.5, 0.),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(10.0, 10.0))),
MeshMaterial3d(materials.add(Color::from(Srgba::gray(0.6)))),
Transform::from_xyz(0., -0.5, 0.),
));

commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(0.0, 1.5, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(0.0, 1.5, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}

fn print(ready: Res<PipelinesReady>) {
Expand All @@ -90,9 +84,3 @@ fn transition(ready: Res<PipelinesReady>, mut next_state: ResMut<NextState<GameS
next_state.set(GameState::Ready);
}
}

fn cleanup<T: Component>(mut commands: Commands, query: Query<Entity, With<T>>) {
for entity in query.iter() {
commands.entity(entity).despawn_recursive();
}
}

0 comments on commit 7079f76

Please sign in to comment.