function distanceToGround(player) {
  let playerY = player.y;
  let playerX = player.x;

  // Check tiles below the player
  for (let i = playerY + 1; i < height(); i++) {
    const tiles = getTile(playerX, i);
    if (tiles.length != 0) {
      for (let tile in tiles) {
        if (!isPlayer(tile.type) && !isItem(tile.type)) {
          return i - playerY - 1;
        }
      }
    }
  }

  return height() - playerY - 1;
}
Calculate the distance to the ground
@param {*} player entity
@returns distance to the ground