projects
/
mandelwow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Shorten glutin symbols in camera.
[mandelwow.git]
/
support
/
camera.rs
diff --git
a/support/camera.rs
b/support/camera.rs
index 9f0e3bac45ea2422d0335a545b0e8c21b158dd28..67beeacd19f8ed48418281e2e1a42571ba8d98f2 100644
(file)
--- a/
support/camera.rs
+++ b/
support/camera.rs
@@
-1,12
+1,15
@@
extern crate glutin;
extern crate glutin;
+use glutin::ElementState::{Pressed, Released};
+use glutin::Event::KeyboardInput;
+use glutin::VirtualKeyCode;
use support::vec3::Vec3;
use support::vec3::norm;
use std::f32;
//use glutin::Event;
use support::vec3::Vec3;
use support::vec3::norm;
use std::f32;
//use glutin::Event;
-//use
glutin::
VirtualKeyCode;
+//use VirtualKeyCode;
#[derive(Default)]
pub struct CameraState {
#[derive(Default)]
pub struct CameraState {
@@
-131,11
+134,11
@@
impl CameraState {
self.pos.2 -= f.2 * 0.01;
}
if self.turning_left {
self.pos.2 -= f.2 * 0.01;
}
if self.turning_left {
- let a: f32 =
-
0.05;
+ let a: f32 = 0.05;
self.dir = Vec3(f.0 * a.cos() + f.2 * a.sin(), f.1, - f.0 * a.sin() + f.2 * a.cos());
}
if self.turning_right {
self.dir = Vec3(f.0 * a.cos() + f.2 * a.sin(), f.1, - f.0 * a.sin() + f.2 * a.cos());
}
if self.turning_right {
- let a: f32 = 0.05;
+ let a: f32 =
-
0.05;
self.dir = Vec3(f.0 * a.cos() + f.2 * a.sin(), f.1, - f.0 * a.sin() + f.2 * a.cos());
}
if self.turning_up {
self.dir = Vec3(f.0 * a.cos() + f.2 * a.sin(), f.1, - f.0 * a.sin() + f.2 * a.cos());
}
if self.turning_up {
@@
-152,64
+155,64
@@
impl CameraState {
pub fn process_input(&mut self, event: &glutin::Event) {
match event {
pub fn process_input(&mut self, event: &glutin::Event) {
match event {
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::Up)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::Up)) => {
self.moving_up = true;
},
self.moving_up = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::Up)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::Up)) => {
self.moving_up = false;
},
self.moving_up = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::Down)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::Down)) => {
self.moving_down = true;
},
self.moving_down = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::Down)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::Down)) => {
self.moving_down = false;
},
self.moving_down = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::Left)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::Left)) => {
self.moving_left = true;
},
self.moving_left = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::Left)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::Left)) => {
self.moving_left = false;
},
self.moving_left = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::Right)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::Right)) => {
self.moving_right = true;
},
self.moving_right = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::Right)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::Right)) => {
self.moving_right = false;
},
self.moving_right = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::A)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::A)) => {
self.turning_left = true;
},
self.turning_left = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::A)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::A)) => {
self.turning_left = false;
},
self.turning_left = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::D)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::D)) => {
self.turning_right = true;
},
self.turning_right = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::D)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::D)) => {
self.turning_right = false;
},
self.turning_right = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::W)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::W)) => {
self.moving_forward = true;
},
self.moving_forward = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::W)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::W)) => {
self.moving_forward = false;
},
self.moving_forward = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::S)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::S)) => {
self.moving_backward = true;
},
self.moving_backward = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::S)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::S)) => {
self.moving_backward = false;
},
self.moving_backward = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::R)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::R)) => {
self.turning_up = true;
},
self.turning_up = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::R)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::R)) => {
self.turning_up = false;
},
self.turning_up = false;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(glutin::
VirtualKeyCode::F)) => {
+ &
KeyboardInput(Pressed, _, Some(
VirtualKeyCode::F)) => {
self.turning_down = true;
},
self.turning_down = true;
},
- &
glutin::Event::KeyboardInput(glutin::ElementState::Released, _, Some(glutin::
VirtualKeyCode::F)) => {
+ &
KeyboardInput(Released, _, Some(
VirtualKeyCode::F)) => {
self.turning_down = false;
},
_ => {}
self.turning_down = false;
},
_ => {}