diff --git a/src/board.rs b/src/board.rs index 7ce6faf..594e7e2 100644 --- a/src/board.rs +++ b/src/board.rs @@ -31,14 +31,14 @@ impl Board { pub fn update_game_state<'a>(&'a mut self, input: &'a mut Input, state: &'a mut State, score: &'a mut Score, tick_count: i32) { - if &input.shape_toggle == &true && &state.shape_toggle == &true { + if input.shape_toggle && state.shape_toggle { // TODO - implement next // state.shape.rotate(tick_count); } // todo: refactor these toggles! - if &input.shape_toggle == &true { - if &state.shape_toggle == &true { + if input.shape_toggle { + if state.shape_toggle { state.shape_toggle = false; } else { state.shape_toggle = true; @@ -56,10 +56,8 @@ impl Board { let paddle_line_segment = self.l_paddle.line_segment(); state.paddle_line = paddle_line_segment.clone(); - - // info!("LINES: count: {:?}, {:?}", &intersection_lines.0.len(), &intersection_lines); - - self.ball = self.ball.update_position(&state, input, score); + self.ball = self.ball.update_position(state, input, score); + info!("", self.ball.current_position.x, self.ball.current_position.y); } pub fn starting_triangle() -> LineSegments { diff --git a/src/geometry/vector.rs b/src/geometry/vector.rs index 3cb2521..e63de75 100644 --- a/src/geometry/vector.rs +++ b/src/geometry/vector.rs @@ -26,9 +26,10 @@ impl Vector { Angle((((f64::atan2(self.x, self.y) / TAU ) + 1.0) % 1.0).abs()) } - pub fn magnitude(&mut self) -> f64 { - f64::sqrt((self.x * self.x) + (self.y * self.y)) - } + // pub fn magnitude(&mut self) -> f64 { + // f64::sqrt((self.x * self.x) + (self.y * self.y)) + // } + } impl ops::Sub for Vector { @@ -90,9 +91,9 @@ fn test_angle() { } -#[test] -fn test_magnitude() { - let magnitude = Vector { x: 2.0, y: 5.0 }.magnitude(); - let expected = 5.385; - assert!( magnitude - expected < 0.01 ); -} +// #[test] +// fn test_magnitude() { +// let magnitude = Vector { x: 2.0, y: 5.0 }.magnitude(); +// let expected = 5.385; +// assert!( magnitude - expected < 0.01 ); +// } diff --git a/src/io.rs b/src/io.rs index a83b515..f318d04 100644 --- a/src/io.rs +++ b/src/io.rs @@ -55,18 +55,11 @@ impl Input { match ch { - 65 | KEY_UP => { self.l_player = Some(Direction::Up); }, // UP KEY - 66 | KEY_DOWN => { self.l_player = Some(Direction::Down); }, // DOWN KEY - // TODO: WHY DOESNT THE DEFAULT KEY_LEFT ETC.. WORK ON MY MAC? - // KEY_DOWN => { self.l_player = Some(Direction::Down); }, - KEY_LEFT => { self.paused_toggle = true; printw("OMG"); ; self.l_player = Some(Direction::Left); }, + 65 | 107 | KEY_UP => { self.l_player = Some(Direction::Up); }, // UP KEY , k + 66 | 106 | KEY_DOWN => { self.l_player = Some(Direction::Down); }, // DOWN KEY, j + KEY_LEFT => { self.paused_toggle = true; ; self.l_player = Some(Direction::Left); }, KEY_RIGHT => { self.l_player = Some(Direction::Right); }, - // KEY_UP => { self.l_player = Some(Direction::Up); }, - - 106 => { self.l_player = Some(Direction::Down); }, // j - 107 => { self.l_player = Some(Direction::Up); }, // k - 114 => { self.restart_toggle = true; }, // r 113 => { self.quit = true; }, //q 112 => { self.paused_toggle = true; }, //p diff --git a/src/main.rs b/src/main.rs index faa1bba..82892b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ extern crate num; extern crate ncurses; extern crate rand; -// #[macro_use] +#[macro_use] extern crate log; extern crate env_logger;