Проектная работа - WIP
This commit is contained in:
@@ -19,15 +19,15 @@ pub fn head_rotation(
|
|||||||
let mut new_direction = direction.clone();
|
let mut new_direction = direction.clone();
|
||||||
new_direction.rotate_left();
|
new_direction.rotate_left();
|
||||||
if !snake_path.push(dst_pos, new_direction) {
|
if !snake_path.push(dst_pos, new_direction) {
|
||||||
trace!("try 1 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
trace!("head_rotation - try 1 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
||||||
dst_pos.shift(&direction);
|
dst_pos.shift(&direction);
|
||||||
if !snake_path.push(dst_pos, new_direction) {
|
if !snake_path.push(dst_pos, new_direction) {
|
||||||
trace!("try 2 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
trace!("head_rotation - try 2 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transform.rotation = new_direction.orientation();
|
transform.rotation = new_direction.orientation();
|
||||||
trace!("running {direction} at {cur_pos} {translation}: go {new_direction} on {dst_pos}");
|
trace!("head_rotation - running {direction} at {cur_pos} {translation}: go {new_direction} on {dst_pos}");
|
||||||
} else if input.just_pressed(KeyCode::ArrowRight) {
|
} else if input.just_pressed(KeyCode::ArrowRight) {
|
||||||
let (mut transform, direction) = query.into_inner();
|
let (mut transform, direction) = query.into_inner();
|
||||||
let translation = transform.translation.clone();
|
let translation = transform.translation.clone();
|
||||||
@@ -36,15 +36,15 @@ pub fn head_rotation(
|
|||||||
let mut new_direction = direction.clone();
|
let mut new_direction = direction.clone();
|
||||||
new_direction.rotate_right();
|
new_direction.rotate_right();
|
||||||
if !snake_path.push(dst_pos, new_direction) {
|
if !snake_path.push(dst_pos, new_direction) {
|
||||||
trace!("try 1 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
trace!("head_rotation - try 1 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
||||||
dst_pos.shift(&direction);
|
dst_pos.shift(&direction);
|
||||||
if !snake_path.push(dst_pos, new_direction) {
|
if !snake_path.push(dst_pos, new_direction) {
|
||||||
trace!("try 2 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
trace!("head_rotation - try 2 failed: cannot push [{dst_pos} => {new_direction}] into SnakePath");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transform.rotation = new_direction.orientation();
|
transform.rotation = new_direction.orientation();
|
||||||
trace!("running {direction} at {cur_pos} {translation}: go {new_direction} on {dst_pos}");
|
trace!("head_rotation - running {direction} at {cur_pos} {translation}: go {new_direction} on {dst_pos}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ pub fn snake_moving(
|
|||||||
let delta = second.1.abs();
|
let delta = second.1.abs();
|
||||||
let pos = Position::from(&*transform);
|
let pos = Position::from(&*transform);
|
||||||
if let Some(dir) = snake_path.peek(&pos) {
|
if let Some(dir) = snake_path.peek(&pos) {
|
||||||
trace!("set new direction for {entity} in {pos} --> {dir}");
|
trace!("snake_moving - set new direction for {entity} in {pos} --> {dir}");
|
||||||
*direction = dir.clone();
|
*direction = dir.clone();
|
||||||
}
|
}
|
||||||
let src = direction.get_coord(&*transform);
|
let src = direction.get_coord(&*transform);
|
||||||
|
|||||||
Reference in New Issue
Block a user