diff --git a/src/main.rs b/src/main.rs index 7652097..2c060ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,7 +112,9 @@ impl Ball { self.color = [ 0.2 + 0.8 * (self.position[0].abs() / bounds_x), 0.2 + 0.8 * (self.position[1].abs() / bounds_y), - 0.2 + 0.6 * ((self.position[0].abs() + self.position[1].abs()) / (bounds_x + bounds_y)), + 0.2 + 0.6 + * ((self.position[0].abs() + self.position[1].abs()) + / (bounds_x + bounds_y)), ]; } // if the y position plus the radius is greater than the bounds_y or the y position minus the radius is less than -bounds_y, then bounce off the wall @@ -124,7 +126,9 @@ impl Ball { self.color = [ 0.2 + 0.8 * (self.position[0].abs() / bounds_x), 0.2 + 0.8 * (self.position[1].abs() / bounds_y), - 0.2 + 0.6 * ((self.position[0].abs() + self.position[1].abs()) / (bounds_x + bounds_y)), + 0.2 + 0.6 + * ((self.position[0].abs() + self.position[1].abs()) + / (bounds_x + bounds_y)), ]; } } @@ -405,10 +409,10 @@ impl State { // Define key mappings: (axis_index, direction_value) let key_mapping = match key_code { // Some is a Rust Type Option that is used to indicate a valid mapping - KeyCode::KeyW => Some((1, 1.0)), // Y-axis, positive - KeyCode::KeyS => Some((1, -1.0)), // Y-axis, negative - KeyCode::KeyA => Some((0, -1.0)), // X-axis, negative - KeyCode::KeyD => Some((0, 1.0)), // X-axis, positive + KeyCode::KeyW => Some((1, 1.0)), // Y-axis, positive + KeyCode::KeyS => Some((1, -1.0)), // Y-axis, negative + KeyCode::KeyA => Some((0, -1.0)), // X-axis, negative + KeyCode::KeyD => Some((0, 1.0)), // X-axis, positive KeyCode::Space if pressed => { self.ball.toggle_control_mode(); return; @@ -561,7 +565,7 @@ impl ApplicationHandler for App { Ok(_) => {} Err(wgpu::SurfaceError::Lost) => state.resize(state.size), Err(wgpu::SurfaceError::OutOfMemory) => event_loop.exit(), - Err(e) => eprintln!("{:?}", e), + Err(e) => eprintln!("{e:?}"), } // Request another frame for continuous animation