From 01d54c88e74e19f478bac959ad3138f5b89a1989 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 24 Dec 2020 14:04:06 -0500 Subject: [PATCH] Using our grid --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9d3d9e8..2ffb03d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,20 +48,20 @@ fn spawn_snake(commands: &mut Commands, materials: Res) { fn snake_movement( keyboard_input: Res>, - mut head_positions: Query<&mut Transform, With>, + mut head_positions: Query<&mut Position, With>, ) { - for mut transform in head_positions.iter_mut() { + for mut pos in head_positions.iter_mut() { if keyboard_input.pressed(KeyCode::Left) { - transform.translation.x -= 2.; + pos.x -= 1; } if keyboard_input.pressed(KeyCode::Right) { - transform.translation.x += 2.; + pos.x += 1; } if keyboard_input.pressed(KeyCode::Down) { - transform.translation.y -= 2.; + pos.y -= 1; } if keyboard_input.pressed(KeyCode::Up) { - transform.translation.y += 2.; + pos.y += 1; } } }