frame_time

This commit is contained in:
2019-07-28 16:36:08 +02:00
parent 8f5716238a
commit c38ffe4638
3 changed files with 17 additions and 6 deletions

View File

@@ -1,12 +1,17 @@
[[button]] [[button]]
name = "QUIT" name = "quit"
scan_code = 1 scan_code = 1
[[button]] [[button]]
name = "RELOAD_SHADERS" name = "reload_shaders"
scan_code = 19 scan_code = 19
ctrl = true ctrl = true
[[button]]
name = "print_framerate"
scan_code = 33
crtl = true
[[button]] [[button]]
name = "w" name = "w"
scan_code = 17 scan_code = 17

View File

@@ -1,2 +1,2 @@
input = true input = false
vulkan_validation_layers = true vulkan_validation_layers = true

View File

@@ -23,17 +23,23 @@ impl Game for TestGame {
} }
fn update(self: &mut Self, game_data: &mut GameData) { 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 // User interaction
if self.input.button_just_released("QUIT") { if self.input.button_just_released("quit") {
game_data.shutdown = true; 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; 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 = 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_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( self.cam_position += self.cam_rotation.invert().rotate_vector(Vector3::new(