Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Commit

Permalink
Add forward and backward movements
Browse files Browse the repository at this point in the history
  • Loading branch information
sunreef committed May 27, 2019
1 parent 58372e1 commit c06732f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions resources/input.ron
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@
"CameraMoveRight": [
[Key(Right)]
],
"CameraMoveForward": [
[Key(LShift), Key(Up)]
],
"CameraMoveBackward": [
[Key(LShift), Key(Down)]
],
},
)
15 changes: 10 additions & 5 deletions src/systems/camera_movement.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use amethyst::{
core::{Named, Transform, Time},
core::{Named, Time, Transform},
ecs::*,
input::InputHandler,
renderer::Camera,
renderer::Camera,
};

#[derive(Default)]
pub struct CameraMovementSystem {
}
pub struct CameraMovementSystem {}

impl<'s> System<'s> for CameraMovementSystem {
type SystemData = (
Expand All @@ -20,7 +19,7 @@ impl<'s> System<'s> for CameraMovementSystem {

fn run(&mut self, (cameras, names, mut transforms, input_handler, time): Self::SystemData) {
let delta_time = time.delta_real_seconds();
let move_factor = 8.0 * delta_time;
let move_factor = 12.0 * delta_time;
for (_, name, transform) in (&cameras, &names, &mut transforms).join() {
if name.name == "Main camera" {
if input_handler.action_is_down("CameraMoveUp").unwrap() {
Expand All @@ -35,6 +34,12 @@ impl<'s> System<'s> for CameraMovementSystem {
if input_handler.action_is_down("CameraMoveRight").unwrap() {
transform.move_right(move_factor);
}
if input_handler.action_is_down("CameraMoveForward").unwrap() {
transform.move_forward(move_factor);
}
if input_handler.action_is_down("CameraMoveBackward").unwrap() {
transform.move_backward(move_factor);
}
}
}
}
Expand Down

0 comments on commit c06732f

Please sign in to comment.