editor: move camera

This commit is contained in:
Pascal Engélibert 2022-08-26 10:16:40 +02:00
parent 02b29bd093
commit 5d2289d1c0
Signed by: tuxmain
GPG key ID: 3504BC6D362F7DCA
2 changed files with 20 additions and 0 deletions

View file

@ -51,6 +51,12 @@ Skip to level `N: u32` with the command `bevyjam <N>`.
Edit the level `N: u32` with the command `bevyjam <N> e`.
### Editor controls
* **Select handles**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all
* **Move handles**: arrows to move one step, Shift+arrows to move continuously
* **Move camera**: CTRL+arrows
## License
GNU AGPL v3, CopyLeft 2022 Pascal Engélibert, Nixon Cheng

View file

@ -184,9 +184,23 @@ fn setup(
fn keyboard_input_system(
keyboard_input: Res<Input<KeyCode>>,
mut camera_query: Query<&mut Transform, (With<Camera>, Without<Draggable>)>,
mut drag_query: Query<(&mut Transform, &Selection, Option<&End>), With<Draggable>>,
mut drag_end_event: EventWriter<DragEndEvent>,
) {
if keyboard_input.pressed(KeyCode::LControl) || keyboard_input.pressed(KeyCode::RControl) {
let mut transform = camera_query.single_mut();
let drag = Vec3 {
x: (keyboard_input.pressed(KeyCode::Right) as i8
- keyboard_input.pressed(KeyCode::Left) as i8) as _,
y: (keyboard_input.pressed(KeyCode::Up) as i8
- keyboard_input.pressed(KeyCode::Down) as i8) as _,
z: 0.,
} * 8.;
transform.translation += drag;
return;
}
let drag = if keyboard_input.pressed(KeyCode::LShift) || keyboard_input.pressed(KeyCode::RShift)
{
Vec3 {