strsToLevel :: [String] -> Level
strsToLevel str = foldl populate emptyLevel { lMax = maxXY } asciiMap
  where
    asciiMap = concat $ zipWith zip coords str
    coords = [[(Coord x y) | x <- [0..]] | y <- [0..]]
    maxX = maximum . map (x . fst) $ asciiMap
    maxY = maximum . map (y . fst) $ asciiMap
    maxXY = Coord maxX maxY
    populate lvl (coord, tile) =
      case tile of
        '#' -> lvl { lWalls  = S.insert coord w}
        '_' -> lvl { lGoals  = S.insert coord g}
        'O' -> lvl { lBlocks = S.insert coord b}
        '@' -> lvl { lStart  = coord }
        _ ->   lvl
        where
          w = lWalls  lvl
          g = lGoals  lvl
          b = lBlocks lvl

-- | True if (x, y) is a Wall tile, else False.
strsToLevel :: [String] -> Level
strsToLevel str = foldl populate emptyLevel { lMax = maxXY } asciiMap
  where
    asciiMap = concat $ zipWith zip coords str
    coords = [[(Coord x y) | x <- [0..]] | y <- [0..]]
    maxX = maximum . map (x . fst) $ asciiMap
    maxY = maximum . map (y . fst) $ asciiMap
    maxXY = Coord maxX maxY
    populate lvl (coord, tile) =
      case tile of
        '#' -> lvl { lWalls  = S.insert coord w}
        '_' -> lvl { lGoals  = S.insert coord g}
        'O' -> lvl { lBlocks = S.insert coord b}
        '@' -> lvl { lStart  = coord }
        _ ->   lvl
        where
          w = lWalls  lvl
          g = lGoals  lvl
          b = lBlocks lvl

-- | True if (x, y) is a Wall tile, else False.
strsToLevel str = foldl populate emptyLevel { lMax = maxXY } asciiMap
  where
    asciiMap = concat $ zipWith zip coords str
    coords = [[(Coord x y) | x <- [0..]] | y <- [0..]]
    maxX = maximum . map (x . fst) $ asciiMap
    maxY = maximum . map (y . fst) $ asciiMap
    maxXY = Coord maxX maxY
    populate lvl (coord, tile) =
      case tile of
        '#' -> lvl { lWalls  = S.insert coord w}
        '_' -> lvl { lGoals  = S.insert coord g}
        'O' -> lvl { lBlocks = S.insert coord b}
        '@' -> lvl { lStart  = coord }
        _ ->   lvl
        where
          w = lWalls  lvl
          g = lGoals  lvl
          b = lBlocks lvl

-- | True if (x, y) is a Wall tile, else False.