Skip to content

Commit

Permalink
Merge pull request #14 from giraugh/chore/bevy-15
Browse files Browse the repository at this point in the history
Upgrade to bevy 0.15
  • Loading branch information
johanhelsing authored Dec 4, 2024
2 parents 5b7d9cd + afd2941 commit e5ede8d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 36 deletions.
14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ repository = "https://github.com/johanhelsing/noisy_bevy"
version = "0.7.0"

[dependencies]
bevy = { version = "0.14", default-features = false, features = [
bevy = { version = "0.15", default-features = false, features = [
"bevy_asset",
"bevy_render"
"bevy_render",
] }

[dev-dependencies]
bevy = { version = "0.14", default-features = false, features = [
bevy = { version = "0.15", default-features = false, features = [
"bevy_sprite",
"bevy_winit",
"x11", # github actions runners don't have libxkbcommon installed, so can't use wayland
"x11", # github actions runners don't have libxkbcommon installed, so can't use wayland
] }
rand = "0.8"
bevy_egui = { version = "0.28", default-features = false, features = ["default_fonts"] }
bevy_pancam = { version = "0.12", features = ["bevy_egui"] }
bevy_pancam = { version = "0.16", features = ["bevy_egui"] }
bevy_egui = { version = "0.31", default-features = false, features = [
"default_fonts",
] }
insta = "1.21"
43 changes: 21 additions & 22 deletions examples/asteroids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy::{
math::{vec2, vec4},
prelude::*,
render::{camera::ScalingMode, render_resource::AsBindGroup},
sprite::{Material2d, Material2dPlugin, MaterialMesh2dBundle},
sprite::{Material2d, Material2dPlugin},
};
// use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_pancam::{PanCam, PanCamPlugin};
Expand All @@ -15,7 +15,7 @@ fn main() {
.add_plugins((
DefaultPlugins,
NoisyShaderPlugin,
PanCamPlugin::default(),
PanCamPlugin,
Material2dPlugin::<AsteroidBackgroundMaterial>::default(),
// WorldInspectorPlugin::new()
))
Expand All @@ -25,10 +25,16 @@ fn main() {
}

fn setup(mut commands: Commands) {
let mut cam = Camera2dBundle::default();
cam.projection.scaling_mode = ScalingMode::FixedVertical(50.);

commands.spawn((cam, PanCam::default()));
commands.spawn((
Camera2d,
OrthographicProjection {
scaling_mode: ScalingMode::FixedVertical {
viewport_height: 70.0,
},
..OrthographicProjection::default_2d()
},
PanCam::default(),
));

commands.spawn(AsteroidBundle::default());
}
Expand Down Expand Up @@ -113,17 +119,14 @@ fn expand_asteroids(
// let o = noisy_bevy::fbm_simplex_2d(p * params.frequency_scale, 3, 2., 0.5)
// * params.amplitude_scale;
if ((x * x + y * y) as f32) < (params.radius + o).powi(2) {
asteroid.spawn(SpriteBundle {
sprite: Sprite {
asteroid.spawn((
Sprite {
color: Color::WHITE.with_luminance(0.2),
custom_size: Some(Vec2::splat(1.)),
..default()
},
transform: Transform::from_translation(Vec3::new(
x as f32, y as f32, 100.,
)),
..default()
});
Transform::from_translation(Vec3::new(x as f32, y as f32, 100.)),
));
}
}
}
Expand All @@ -141,15 +144,11 @@ fn expand_asteroids(

let quad_handle = meshes.add(Mesh::from(Rectangle::from_size(Vec2::new(100.0, 100.0))));

asteroid.spawn(MaterialMesh2dBundle {
mesh: quad_handle.into(),
material: material_handle,
transform: Transform {
translation: Vec3::new(0.0, 0.0, 1.5),
..default()
},
..default()
});
asteroid.spawn((
Mesh2d(quad_handle),
MeshMaterial2d(material_handle),
Transform::from_translation(Vec3::new(0.0, 0.0, 1.5)),
));
});
}
}
22 changes: 14 additions & 8 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ fn main() {
}

fn setup(mut commands: Commands) {
let mut cam = Camera2dBundle::default();
cam.projection.scaling_mode = ScalingMode::FixedVertical(70.);
commands.spawn((cam, PanCam::default()));
commands.spawn((
Camera2d,
OrthographicProjection {
scaling_mode: ScalingMode::FixedVertical {
viewport_height: 70.0,
},
..OrthographicProjection::default_2d()
},
PanCam::default(),
));

const FREQUENCY_SCALE: f32 = 0.05;
const AMPLITUDE_SCALE: f32 = 4.0;
Expand All @@ -40,15 +47,14 @@ fn setup(mut commands: Commands) {
let height = RADIUS + offset - ((x * x + y * y) as f32).sqrt();

// spawn a corresponding tile with a color thats more white the higher the height
commands.spawn(SpriteBundle {
sprite: Sprite {
commands.spawn((
Sprite {
color: Color::WHITE.with_luminance(height * 0.03),
custom_size: Some(Vec2::splat(1.)),
..default()
},
transform: Transform::from_translation(Vec3::new(x as f32, y as f32, 100.)),
..default()
});
Transform::from_translation(Vec3::new(x as f32, y as f32, 100.)),
));
}
}
}

0 comments on commit e5ede8d

Please sign in to comment.