diff --git a/microbit/src/11-snake-game/Cargo.toml b/microbit/src/11-snake-game/Cargo.toml index de02fcb7..15fa3a18 100644 --- a/microbit/src/11-snake-game/Cargo.toml +++ b/microbit/src/11-snake-game/Cargo.toml @@ -17,13 +17,13 @@ optional = true [dependencies] cortex-m = "0.7.3" cortex-m-rt = "0.7.0" -rtt-target = { version = "0.3.1", features = ["cortex-m"] } -panic-rtt-target = { version = "0.1.2", features = ["cortex-m"] } lsm303agr = "0.2.2" nb = "1.0.0" libm = "0.2.1" heapless = "0.8.0" tiny-led-matrix = "1.0.1" +rtt-target = "0.6.1" +panic-rtt-target = "0.2.0" [features] v2 = ["microbit-v2"] diff --git a/microbit/src/11-snake-game/src/game.rs b/microbit/src/11-snake-game/src/game.rs index 35523fdb..3246843d 100644 --- a/microbit/src/11-snake-game/src/game.rs +++ b/microbit/src/11-snake-game/src/game.rs @@ -88,9 +88,9 @@ pub enum GameStatus { /// The outcome of a single move/step. enum StepOutcome { /// Grid full (player wins) - Full(Coords), + Full, /// Snake has collided with itself (player loses) - Collision(Coords), + Collision, /// Snake has eaten some food Eat(Coords), /// Snake has moved (and nothing else has happened) @@ -248,13 +248,13 @@ impl Game { // won't actually be any collision (as the tail will have moved by the time the head // moves onto the tile) if next_move != *self.snake.tail.peek().unwrap() { - StepOutcome::Collision(next_move) + StepOutcome::Collision } else { StepOutcome::Move(next_move) } } else if next_move == self.food_coords { if self.snake.tail.len() == 23 { - StepOutcome::Full(next_move) + StepOutcome::Full } else { StepOutcome::Eat(next_move) } @@ -266,8 +266,8 @@ impl Game { /// Handle the outcome of a step, updating the game's internal state. fn handle_step_outcome(&mut self, outcome: StepOutcome) { self.status = match outcome { - StepOutcome::Collision(_) => GameStatus::Lost, - StepOutcome::Full(_) => GameStatus::Won, + StepOutcome::Collision => GameStatus::Lost, + StepOutcome::Full => GameStatus::Won, StepOutcome::Eat(c) => { self.snake.move_snake(c, true); self.place_food(); @@ -333,4 +333,4 @@ impl Game { } values } -} \ No newline at end of file +} diff --git a/microbit/src/11-snake-game/src/main.rs b/microbit/src/11-snake-game/src/main.rs index 7f6cebf5..70d4383d 100644 --- a/microbit/src/11-snake-game/src/main.rs +++ b/microbit/src/11-snake-game/src/main.rs @@ -22,7 +22,7 @@ use crate::game::{Game, GameStatus}; #[entry] fn main() -> ! { rtt_init_print!(); - let mut board = Board::take().unwrap(); + let board = Board::take().unwrap(); let mut timer = Timer::new(board.TIMER0).into_periodic(); let mut rng = Rng::new(board.RNG); let mut game = Game::new(rng.random_u32());