Added keyboard movement for easier debugging
parent
c1894235ba
commit
dc0f163c1d
|
|
@ -118,13 +118,32 @@ fn free_system(
|
|||
mut free_query: Query<(&mut Transform, &GameCamera, &OrthographicProjection)>,
|
||||
mut mouse_events: EventReader<MouseMotion>,
|
||||
mouse_input: Res<Input<MouseButton>>,
|
||||
key_input: Res<Input<KeyCode>>,
|
||||
time: Res<Time>,
|
||||
) {
|
||||
let raw_mouse_motion: Vec2 = mouse_events.iter().map(|e| e.delta).sum();
|
||||
for (mut transform, camera, projection) in free_query.iter_mut() {
|
||||
if camera.mode == CameraMode::Free {
|
||||
let mouse_motion = raw_mouse_motion * projection.scale * Vec2::new(-1.0, 1.0);
|
||||
let mut motion = Vec2::ZERO;
|
||||
if mouse_input.pressed(MouseButton::Middle) {
|
||||
input_movement(&mut transform, mouse_motion)
|
||||
motion += raw_mouse_motion * projection.scale * Vec2::new(-1.0, 1.0);
|
||||
}
|
||||
motion.x = match (key_input.pressed(KeyCode::A), key_input.pressed(KeyCode::D)) {
|
||||
(true, false) => -1.0,
|
||||
(false, true) => 1.0,
|
||||
(_, _) => 0.0,
|
||||
} * projection.scale
|
||||
* time.delta_seconds()
|
||||
* 100.0;
|
||||
motion.y = match (key_input.pressed(KeyCode::S), key_input.pressed(KeyCode::W)) {
|
||||
(true, false) => -1.0,
|
||||
(false, true) => 1.0,
|
||||
(_, _) => 0.0,
|
||||
} * projection.scale
|
||||
* time.delta_seconds()
|
||||
* 100.0;
|
||||
if motion != Vec2::ZERO {
|
||||
input_movement(&mut transform, motion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue