/**
   * Snaps a coordinate against the bounds of the world so that it may not pass out of the visible
   * area of the world.
   *
   * @param worldX An x-coordinate in world units.
   * @return An x-coordinate that is guaranteed not to expose the edges of the world.
   */
  public float snapFocalPointToWorldBoundsX(float worldX) {
    float focalPositionX = worldX;
    final float width = sSystemRegistry.contextParameters.gameWidth;
    final LevelSystem level = sSystemRegistry.levelSystem;
    if (level != null) {
      final float worldPixelWidth = Math.max(level.getLevelWidth(), width);
      final float rightEdge = focalPositionX + (width / 2.0f);
      final float leftEdge = focalPositionX - (width / 2.0f);

      if (rightEdge > worldPixelWidth) {
        focalPositionX = worldPixelWidth - (width / 2.0f);
      } else if (leftEdge < 0) {
        focalPositionX = width / 2.0f;
      }
    }
    return focalPositionX;
  }
  /**
   * Snaps a coordinate against the bounds of the world so that it may not pass out of the visible
   * area of the world.
   *
   * @param worldY A y-coordinate in world units.
   * @return A y-coordinate that is guaranteed not to expose the edges of the world.
   */
  public float snapFocalPointToWorldBoundsY(float worldY) {
    float focalPositionY = worldY;

    final float height = sSystemRegistry.contextParameters.gameHeight;
    final LevelSystem level = sSystemRegistry.levelSystem;
    if (level != null) {
      final float worldPixelHeight =
          Math.max(level.getLevelHeight(), sSystemRegistry.contextParameters.gameHeight);
      final float topEdge = focalPositionY + (height / 2.0f);
      final float bottomEdge = focalPositionY - (height / 2.0f);

      if (topEdge > worldPixelHeight) {
        focalPositionY = worldPixelHeight - (height / 2.0f);
      } else if (bottomEdge < 0) {
        focalPositionY = height / 2.0f;
      }
    }

    return focalPositionY;
  }