Проектная работа - WIP
This commit is contained in:
@@ -7,10 +7,6 @@ pub const GRID_SIZE: u8 = 48;
|
||||
pub const HEAD_SIZE: u8 = (GRID_SIZE as f32 * 1.1) as u8;
|
||||
pub const SNAKE_VELOCITY: u8 = (GRID_SIZE as f32 / 1.0) as u8;
|
||||
|
||||
/// Координатная сетка
|
||||
#[derive(Component)]
|
||||
pub struct Grid;
|
||||
|
||||
/// Голова змеи
|
||||
#[derive(Component)]
|
||||
pub struct Head;
|
||||
@@ -118,9 +114,9 @@ impl SnakePath {
|
||||
self.0.get(&key).cloned()
|
||||
}
|
||||
|
||||
pub fn pop(&mut self, transform: &Transform) -> Option<Direction> {
|
||||
pub fn drop(&mut self, transform: &Transform) -> Option<(i16, i16, Direction)> {
|
||||
let key = SnakePath::to_key(transform);
|
||||
self.0.remove(&key)
|
||||
self.0.remove(&key).map(|d| (key.0, key.1, d))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +135,7 @@ mod test {
|
||||
assert!(snake_path.pick(&Transform::default()) == Some(Direction::default()));
|
||||
assert_eq!(snake_path.0.len(), 1);
|
||||
|
||||
assert!(snake_path.pop(&Transform::default()) == Some(Direction::default()));
|
||||
assert!(snake_path.drop(&Transform::default()) == Some((0, 0, Direction::default())));
|
||||
assert_eq!(snake_path.0.len(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user