Using our grid

This commit is contained in:
Timothy Warren 2020-12-24 14:04:06 -05:00
parent 96675b42cf
commit 01d54c88e7
1 changed files with 6 additions and 6 deletions

View File

@ -48,20 +48,20 @@ fn spawn_snake(commands: &mut Commands, materials: Res<Materials>) {
fn snake_movement( fn snake_movement(
keyboard_input: Res<Input<KeyCode>>, keyboard_input: Res<Input<KeyCode>>,
mut head_positions: Query<&mut Transform, With<SnakeHead>>, mut head_positions: Query<&mut Position, With<SnakeHead>>,
) { ) {
for mut transform in head_positions.iter_mut() { for mut pos in head_positions.iter_mut() {
if keyboard_input.pressed(KeyCode::Left) { if keyboard_input.pressed(KeyCode::Left) {
transform.translation.x -= 2.; pos.x -= 1;
} }
if keyboard_input.pressed(KeyCode::Right) { if keyboard_input.pressed(KeyCode::Right) {
transform.translation.x += 2.; pos.x += 1;
} }
if keyboard_input.pressed(KeyCode::Down) { if keyboard_input.pressed(KeyCode::Down) {
transform.translation.y -= 2.; pos.y -= 1;
} }
if keyboard_input.pressed(KeyCode::Up) { if keyboard_input.pressed(KeyCode::Up) {
transform.translation.y += 2.; pos.y += 1;
} }
} }
} }