Skip to content

Commit

Permalink
update to bevy 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
shnewto committed Feb 29, 2024
1 parent 4495f03 commit be2ebc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ keywords = ["bevy", "rapier", "png", "collider", "2d"]
readme = "README.md"

[dependencies]
bevy = "0.12.0"
bevy_rapier2d = "0.23.0"
bevy = "0.13.0"
bevy_rapier2d = "0.25.0"

[dev-dependencies]
bevy_prototype_lyon = "0.10.0"
bevy_prototype_lyon = "0.11.0"
indoc = "2.0.4"

[[example]]
Expand Down
27 changes: 14 additions & 13 deletions examples/colliders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub struct GameAsset {

fn main() {
App::new()
.add_state::<AppState>()
.init_state::<AppState>()
.add_plugins(
DefaultPlugins
.set(WindowPlugin {
Expand All @@ -193,6 +193,7 @@ fn main() {
features: WgpuFeatures::POLYGON_MODE_LINE,
..default()
}),
..default()
}),
)
.insert_resource(GameAsset::default())
Expand Down Expand Up @@ -255,29 +256,29 @@ pub fn camera_spawn(mut commands: Commands) {

pub fn camera_movement(
mut query: Query<(&Camera, &mut OrthographicProjection, &mut Transform)>,
keys: Res<Input<KeyCode>>,
keys: Res<ButtonInput<KeyCode>>,
) {
for (_, mut projection, mut transform) in query.iter_mut() {
if keys.pressed(KeyCode::Left) {
if keys.pressed(KeyCode::ArrowLeft) {
transform.translation.x += 10.0;
}
if keys.pressed(KeyCode::Right) {
if keys.pressed(KeyCode::ArrowRight) {
transform.translation.x -= 10.0;
}

if keys.pressed(KeyCode::Up) {
if keys.pressed(KeyCode::ArrowUp) {
transform.translation.y -= 10.0;
}

if keys.pressed(KeyCode::Down) {
if keys.pressed(KeyCode::ArrowDown) {
transform.translation.y += 10.0;
}

if keys.pressed(KeyCode::W) {
if keys.pressed(KeyCode::KeyW) {
projection.scale -= 0.01;
}

if keys.pressed(KeyCode::S) {
if keys.pressed(KeyCode::KeyS) {
projection.scale += 0.01;
}
}
Expand Down Expand Up @@ -353,7 +354,7 @@ pub fn controls_text_spawn(mut commands: Commands, game_assets: Res<GameAsset>)
color: Color::rgb(0.9, 0.9, 0.9),
},
}],
alignment: TextAlignment::Left,
justify: JustifyText::Left,
..default()
},
..Default::default()
Expand All @@ -364,17 +365,17 @@ pub fn controls_text_spawn(mut commands: Commands, game_assets: Res<GameAsset>)
});
}

pub fn car_movement(mut query: Query<(&Car, &mut Transform)>, keys: Res<Input<KeyCode>>) {
pub fn car_movement(mut query: Query<(&Car, &mut Transform)>, keys: Res<ButtonInput<KeyCode>>) {
for (car, mut transform) in query.iter_mut() {
if keys.pressed(KeyCode::D) {
if keys.pressed(KeyCode::KeyD) {
transform.translation.x += 5.0;
}

if keys.pressed(KeyCode::A) {
if keys.pressed(KeyCode::KeyA) {
transform.translation.x -= 5.0;
}

if keys.pressed(KeyCode::Key1) {
if keys.pressed(KeyCode::Digit1) {
*transform =
Transform::from_xyz(car.initial_xyz.x, car.initial_xyz.y, car.initial_xyz.z);
}
Expand Down

0 comments on commit be2ebc8

Please sign in to comment.