diff --git a/config/input.toml b/config/input.toml index 1463bdf..f541a2a 100644 --- a/config/input.toml +++ b/config/input.toml @@ -1,12 +1,17 @@ [[button]] -name = "QUIT" +name = "quit" scan_code = 1 [[button]] -name = "RELOAD_SHADERS" +name = "reload_shaders" scan_code = 19 ctrl = true +[[button]] +name = "print_framerate" +scan_code = 33 +crtl = true + [[button]] name = "w" scan_code = 17 diff --git a/config/log.toml b/config/log.toml index 93cad95..893e4a0 100644 --- a/config/log.toml +++ b/config/log.toml @@ -1,2 +1,2 @@ -input = true +input = false vulkan_validation_layers = true \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index b7af82b..53addbe 100644 --- a/src/main.rs +++ b/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(