private void UpdatePosition(Snake mySnake, Vector3 gravityDirection, Food theFood) { if (Math.Abs(gravityDirection.X) > Math.Abs(gravityDirection.Y) && gravityDirection.X < 0 && mySnake.GetHeadX() - 1 != mySnake.GetBody().GetBodyFrontX()) { if (mySnake.GetHeadX() - 1 == theFood.getFoodX() && mySnake.GetHeadY() == theFood.getFoodY()) { mySnake.SnakeEat(mySnake.GetHeadX() - 1, mySnake.GetHeadY()); theFood = null; } else if (mySnake.GetHeadX() > 0) { mySnake.SnakeMove(mySnake.GetHeadX() - 1, mySnake.GetHeadY()); } } else if (Math.Abs(gravityDirection.X) > Math.Abs(gravityDirection.Y) && gravityDirection.X > 0 && mySnake.GetHeadX() + 1 != mySnake.GetBody().GetBodyFrontX()) { if (mySnake.GetHeadX() + 1 == theFood.getFoodX() && mySnake.GetHeadY() == theFood.getFoodY()) { mySnake.SnakeEat(mySnake.GetHeadX() + 1, mySnake.GetHeadY()); theFood = null; } else if (mySnake.GetHeadX() < 7) { mySnake.SnakeMove(mySnake.GetHeadX() + 1, mySnake.GetHeadY()); } } if (Math.Abs(gravityDirection.X) < Math.Abs(gravityDirection.Y) && gravityDirection.Y < 0 && mySnake.GetHeadY() - 1 != mySnake.GetBody().GetBodyFrontY()) { if (mySnake.GetHeadX() == theFood.getFoodX() && mySnake.GetHeadY() - 1 == theFood.getFoodY()) { mySnake.SnakeEat(mySnake.GetHeadX(), mySnake.GetHeadY() - 1); theFood = null; } else if (mySnake.GetHeadY() > 0) { mySnake.SnakeMove(mySnake.GetHeadX(), mySnake.GetHeadY() - 1); } } else if (Math.Abs(gravityDirection.X) < Math.Abs(gravityDirection.Y) && gravityDirection.Y > 0 && mySnake.GetHeadY() + 1 != mySnake.GetBody().GetBodyFrontY()) { if (mySnake.GetHeadX() == theFood.getFoodX() && mySnake.GetHeadY() + 1 == theFood.getFoodY()) { mySnake.SnakeEat(mySnake.GetHeadX(), mySnake.GetHeadY() + 1); theFood = null; } else if (mySnake.GetHeadY() < 7) { mySnake.SnakeMove(mySnake.GetHeadX(), mySnake.GetHeadY() + 1); } } }