Compare commits
No commits in common. "9e16c22eb5fdf7a55cb20c8df7599b38648fd85c" and "04fe103b25adb2e48faa59834850bf367798937b" have entirely different histories.
9e16c22eb5
...
04fe103b25
@ -8,9 +8,3 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.5", features = ["dynamic"] }
|
bevy = { version = "0.5", features = ["dynamic"] }
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
|
||||||
opt-level = 3
|
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
opt-level = 1
|
|
||||||
|
@ -19,6 +19,5 @@ fn main() {
|
|||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup.system())
|
||||||
.add_startup_system(add_player.system())
|
.add_startup_system(add_player.system())
|
||||||
.add_system(player_movement.system())
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
@ -50,35 +50,6 @@ pub fn add_player(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn player_movement(
|
|
||||||
keyboard_input: Res<Input<KeyCode>>,
|
|
||||||
mut query: Query<(&Player, &mut Transform)>,
|
|
||||||
time: Res<Time>,
|
|
||||||
) {
|
|
||||||
if let Ok((_, mut transform)) = query.single_mut() {
|
|
||||||
let mut direction = Vec2::ZERO;
|
|
||||||
|
|
||||||
if keyboard_input.pressed(KeyCode::A) {
|
|
||||||
direction.x -= 1.0;
|
|
||||||
}
|
|
||||||
if keyboard_input.pressed(KeyCode::D) {
|
|
||||||
direction.x += 1.0;
|
|
||||||
}
|
|
||||||
if keyboard_input.pressed(KeyCode::S) {
|
|
||||||
direction.y -= 1.0;
|
|
||||||
}
|
|
||||||
if keyboard_input.pressed(KeyCode::W) {
|
|
||||||
direction.y += 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
let translation = &mut transform.translation;
|
|
||||||
let delta_seconds = time.delta_seconds();
|
|
||||||
|
|
||||||
translation.x += delta_seconds * direction.x * 100.0;
|
|
||||||
translation.y += delta_seconds * direction.y * 100.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn greet_player(
|
pub fn greet_player(
|
||||||
query: Query<&Name, With<Player>>,
|
query: Query<&Name, With<Player>>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user