diff --git a/app/Main.hs b/app/Main.hs index 122f99f..4e6d195 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -7,8 +7,8 @@ import Data.Map (Map) import Data.Map qualified as Map import Graphics.Vty import System.Environment ( getArgs ) -import System.Directory -import System.FilePath +import System.Directory ( listDirectory ) +import System.FilePath ( (), takeBaseName ) import Model import Rendering ( render ) diff --git a/app/Model.hs b/app/Model.hs index 453bc61..9e8afab 100644 --- a/app/Model.hs +++ b/app/Model.hs @@ -52,26 +52,12 @@ winCondition world = where coverage = Set.fromList $ map boxLocation $ Map.elems (worldBoxes world) -makeWalls :: [String] -> Array Coord Bool -makeWalls rows = listArray ((ylo,xlo),(yhi,xhi)) (map (' '/=) (concat rows)) - where - h = length rows - w = length (head rows) - (xlo,xhi) = mkRange w - (ylo,yhi) = mkRange h - -mkRange :: Int -> (Int,Int) -mkRange n = (- (n-1)`div`2, n`div`2) boxSize :: World -> Box -> Int boxSize world box = yhi-ylo+1 where ((ylo,_),(yhi,_)) = bounds (boxWalls world box) - -solid :: Int -> Array Coord Bool -solid n = makeWalls (replicate n (replicate n 'x')) - move :: World -> (Int,Int) -> World move world dir = case moveBlock world Map.empty (myLocation world) dir 0 of