Проектная работа - WIP
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
domain::{Direction, GRID_SIZE, GridBarier, Head, Position, SnakePath, Tail, Velocity},
|
||||
domain::{Collision, Direction, FIELD_SIZE, GRID_SIZE, GridBarier, Head, Position, SnakePath, Tail, Velocity},
|
||||
tools::split_by_grid,
|
||||
};
|
||||
|
||||
@@ -109,3 +109,13 @@ pub fn snake_moving(
|
||||
moving(velocity, &time, &mut direction, &mut transform, entity, &mut commands, switch_direction);
|
||||
}
|
||||
}
|
||||
|
||||
/// Система отслеживания столкновений с границей
|
||||
pub fn check_bounds_colisions(head: Single<(&Transform,), (With<Head>,)>, mut commands: Commands) {
|
||||
let (head_transform,) = head.into_inner();
|
||||
let (x, y) = (head_transform.translation.x, head_transform.translation.y);
|
||||
const SIDE: f32 = (FIELD_SIZE as f32 / 2.0) * GRID_SIZE as f32;
|
||||
if x < -SIDE || x > SIDE || y < -SIDE || y > SIDE {
|
||||
commands.trigger(Collision::Bounds);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user