private void CheckCollisionWithFood() { if (SnakeBody[0].GetXCoordinate() == food.GetXCoordinate() && SnakeBody[0].GetYCoordinate() == food.GetYCoordinate()) { Eat(); } }
private void CheckCollisionWithBorder(int maxXPos, int maxYPos, Circle snakePart) { if (snakePart.GetXCoordinate() < 0 || snakePart.GetYCoordinate() < 0 || snakePart.GetXCoordinate() > maxXPos || snakePart.GetYCoordinate() > maxYPos) { Die(); } }
private void CheckCollisionWithSelf(Circle snakePart) { for (int j = 1; j < SnakeBody.Count; j++) { if (snakePart.GetXCoordinate() == SnakeBody[j].GetXCoordinate() && snakePart.GetYCoordinate() == SnakeBody[j].GetYCoordinate()) { Die(); } } }
private void MoveSnake(Circle snakePart, Circle previousSnakePart) { snakePart.SetXCoordinate(previousSnakePart.GetXCoordinate()); snakePart.SetYCoordinate(previousSnakePart.GetYCoordinate()); }