frame_time
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -23,17 +23,23 @@ impl Game for TestGame {
|
||||
}
|
||||
|
||||
fn update(self: &mut Self, game_data: &mut GameData) {
|
||||
game_data.push_constants.time = game_data.start_time.elapsed().unwrap().as_millis() as f32 / 1000.0;
|
||||
let new_time = game_data.start_time.elapsed().unwrap().as_millis() as f32 / 1000.0;
|
||||
let frame_time = new_time - game_data.push_constants.time;
|
||||
game_data.push_constants.time = new_time;
|
||||
|
||||
// User interaction
|
||||
if self.input.button_just_released("QUIT") {
|
||||
if self.input.button_just_released("quit") {
|
||||
game_data.shutdown = true;
|
||||
}
|
||||
|
||||
if self.input.button_just_pressed("RELOAD_SHADERS") {
|
||||
if self.input.button_just_pressed("reload_shaders") {
|
||||
game_data.recreate_pipeline = true;
|
||||
}
|
||||
|
||||
if self.input.button_down("print_framerate") {
|
||||
println!("{:.0} ms / {:.0} FPS", frame_time * 1000.0, 1.0 / frame_time);
|
||||
}
|
||||
|
||||
self.cam_rotation = self.cam_rotation * Quaternion::from_angle_z(Deg(self.input.get_axis("look_horizontal") * 0.05));
|
||||
self.cam_rotation = Quaternion::from_angle_x(Deg(self.input.get_axis("look_vertical") * 0.05)) * self.cam_rotation;
|
||||
self.cam_position += self.cam_rotation.invert().rotate_vector(Vector3::new(
|
||||
|
||||
Reference in New Issue
Block a user