Skip to content

Commit

Permalink
Merge pull request #105 from NiklasEi/update_to_bevy_0_13
Browse files Browse the repository at this point in the history
Update to Bevy 0.13
  • Loading branch information
NiklasEi authored Feb 29, 2024
2 parents b66bfe9 + ae7b76c commit 116e0ef
Show file tree
Hide file tree
Showing 8 changed files with 735 additions and 517 deletions.
1,217 changes: 719 additions & 498 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dev = [
# All of Bevy's default features exept for the audio related ones (bevy_audio, vorbis), since they clash with bevy_kira_audio
# and android_shared_stdcxx, since that is covered in `mobile`
[dependencies]
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"animation",
"bevy_asset",
"bevy_gilrs",
Expand All @@ -60,15 +60,16 @@ bevy = { version = "0.12", default-features = false, features = [
"tonemapping_luts",
"default_font",
"webgl2",
"bevy_debug_stepping",
] }
bevy_kira_audio = { version = "0.18" }
bevy_asset_loader = { version = "0.19" }
bevy_kira_audio = { version = "0.19" }
bevy_asset_loader = { version = "0.20" }
rand = { version = "0.8.3" }
webbrowser = { version = "0.8", features = ["hardened"] }

# keep the following in sync with Bevy's dependencies
winit = { version = "0.28.7", default-features = false }
winit = { version = "0.29", default-features = false }
image = { version = "0.24", default-features = false }

[build-dependencies]
embed-resource = "1.4"
embed-resource = "1"
2 changes: 0 additions & 2 deletions build/web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ body {
}

#bevy {
width: 0;
height: 0;
z-index: 2;
}
2 changes: 1 addition & 1 deletion mobile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ crate-type = ["staticlib", "cdylib"]

[dependencies]
bevy_game = { path = ".." } # ToDo
bevy = { version = "0.12", default-features = false }
bevy = { version = "0.13", default-features = false }

# As long as Kira doesn't expose a feature for this, we need to enable it
# See https://github.com/tesselode/kira/pull/51
Expand Down
14 changes: 7 additions & 7 deletions src/actions/game_control.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::{Input, KeyCode, Res};
use bevy::prelude::{ButtonInput, KeyCode, Res};

pub enum GameControl {
Up,
Expand All @@ -8,25 +8,25 @@ pub enum GameControl {
}

impl GameControl {
pub fn pressed(&self, keyboard_input: &Res<Input<KeyCode>>) -> bool {
pub fn pressed(&self, keyboard_input: &Res<ButtonInput<KeyCode>>) -> bool {
match self {
GameControl::Up => {
keyboard_input.pressed(KeyCode::W) || keyboard_input.pressed(KeyCode::Up)
keyboard_input.pressed(KeyCode::KeyW) || keyboard_input.pressed(KeyCode::ArrowUp)
}
GameControl::Down => {
keyboard_input.pressed(KeyCode::S) || keyboard_input.pressed(KeyCode::Down)
keyboard_input.pressed(KeyCode::KeyS) || keyboard_input.pressed(KeyCode::ArrowDown)
}
GameControl::Left => {
keyboard_input.pressed(KeyCode::A) || keyboard_input.pressed(KeyCode::Left)
keyboard_input.pressed(KeyCode::KeyA) || keyboard_input.pressed(KeyCode::ArrowLeft)
}
GameControl::Right => {
keyboard_input.pressed(KeyCode::D) || keyboard_input.pressed(KeyCode::Right)
keyboard_input.pressed(KeyCode::KeyD) || keyboard_input.pressed(KeyCode::ArrowRight)
}
}
}
}

pub fn get_movement(control: GameControl, input: &Res<Input<KeyCode>>) -> f32 {
pub fn get_movement(control: GameControl, input: &Res<ButtonInput<KeyCode>>) -> f32 {
if control.pressed(input) {
1.0
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Actions {

pub fn set_movement_actions(
mut actions: ResMut<Actions>,
keyboard_input: Res<Input<KeyCode>>,
keyboard_input: Res<ButtonInput<KeyCode>>,
touch_input: Res<Touches>,
player: Query<&Transform, With<Player>>,
camera: Query<(&Camera, &GlobalTransform), With<Camera2d>>,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct GamePlugin;

impl Plugin for GamePlugin {
fn build(&self, app: &mut App) {
app.add_state::<GameState>().add_plugins((
app.init_state::<GameState>().add_plugins((
LoadingPlugin,
MenuPlugin,
ActionsPlugin,
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ fn main() {
title: "Bevy game".to_string(), // ToDo
// Bind to canvas included in `index.html`
canvas: Some("#bevy".to_owned()),
// The canvas size is constrained in index.html and build/web/styles.css
fit_canvas_to_parent: true,
// Tells wasm not to override default event handling, like F5 and Ctrl+R
prevent_default_event_handling: false,
..default()
Expand Down

0 comments on commit 116e0ef

Please sign in to comment.