Проектная работа - WIP
This commit is contained in:
+17
-13
@@ -13,20 +13,24 @@ pub fn head_rotation(
|
||||
) {
|
||||
if input.just_pressed(KeyCode::ArrowLeft) {
|
||||
let (mut transform, direction) = query.into_inner();
|
||||
let next_pos = direction.next_pos(&*transform);
|
||||
let mut direction = direction.clone();
|
||||
direction.rotate_left();
|
||||
snake_path.insert(next_pos, direction);
|
||||
transform.rotation = direction.orientation();
|
||||
trace!("go {direction} on {next_pos}");
|
||||
let translation = transform.translation.clone();
|
||||
let cur_pos = Position::from(&*transform);
|
||||
let dst_pos = direction.dst_pos(&*transform);
|
||||
let mut new_direction = direction.clone();
|
||||
new_direction.rotate_left();
|
||||
snake_path.insert(dst_pos, new_direction);
|
||||
transform.rotation = new_direction.orientation();
|
||||
trace!("running {direction} at {cur_pos} {translation}: go {new_direction} on {dst_pos}");
|
||||
} else if input.just_pressed(KeyCode::ArrowRight) {
|
||||
let (mut transform, direction) = query.into_inner();
|
||||
let next_pos = direction.next_pos(&*transform);
|
||||
let mut direction = direction.clone();
|
||||
direction.rotate_right();
|
||||
snake_path.insert(next_pos, direction);
|
||||
transform.rotation = direction.orientation();
|
||||
trace!("go {direction} on {next_pos}");
|
||||
let translation = transform.translation.clone();
|
||||
let cur_pos = Position::from(&*transform);
|
||||
let dst_pos = direction.dst_pos(&*transform);
|
||||
let mut new_direction = direction.clone();
|
||||
new_direction.rotate_right();
|
||||
snake_path.insert(dst_pos, new_direction);
|
||||
transform.rotation = new_direction.orientation();
|
||||
trace!("running {direction} at {cur_pos} {translation}: go {new_direction} on {dst_pos}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +56,7 @@ pub fn snake_moving(
|
||||
let delta = second.1.abs();
|
||||
let pos = Position::from(&*transform);
|
||||
if let Some(dir) = snake_path.get(&pos) {
|
||||
trace!("set new direction in {pos:?} --> {dir:?}");
|
||||
trace!("set new direction for {entity} in {pos} --> {dir}");
|
||||
*direction = dir.clone();
|
||||
}
|
||||
let src = direction.get_coord(&*transform);
|
||||
|
||||
Reference in New Issue
Block a user