about summary refs log tree commit diff stats
path: root/Fallen/Map.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Fallen/Map.hs')
-rw-r--r--Fallen/Map.hs12
1 files changed, 0 insertions, 12 deletions
diff --git a/Fallen/Map.hs b/Fallen/Map.hs index 96c6467..a33b696 100644 --- a/Fallen/Map.hs +++ b/Fallen/Map.hs
@@ -28,15 +28,9 @@ module Fallen.Map
28 inBounds m (x,y) = let (w,h) = dimension m in (x >= 0) && (x < w) && (y >= 0) && (y < h) 28 inBounds m (x,y) = let (w,h) = dimension m in (x >= 0) && (x < w) && (y >= 0) && (y < h)
29 29
30 -- getTileAtPos :: Map -> Point -> Tile 30 -- getTileAtPos :: Map -> Point -> Tile
31 --getTileAtPos m p = if (inBounds m p)
32 -- then mapdata m p
33 -- else background m
34 getTileAtPos m p = fromMaybe (background m) $ lookup p $ mapdata m 31 getTileAtPos m p = fromMaybe (background m) $ lookup p $ mapdata m
35 32
36 -- findTileInMap :: Map -> Tile -> [Point] 33 -- findTileInMap :: Map -> Tile -> [Point]
37-- findTileInMap m t = filter (\p -> t == mapdata m p) rawPoints where
38-- (w,h) = dimension m
39-- rawPoints = [(x,y) | x <- [0..w-1], y <- [0..h-1]]
40 findTileInMap m t = map fst $ filter ((== t) . snd) $ mapdata m 34 findTileInMap m t = map fst $ filter ((== t) . snd) $ mapdata m
41 35
42 -- updateMap updates the tiles at the given position in the map 36 -- updateMap updates the tiles at the given position in the map
@@ -48,8 +42,6 @@ module Fallen.Map
48 else case lookup p xs of 42 else case lookup p xs of
49 Just _ -> Map d (map (\(p1,t1) -> if p1 == p then (p,t) else (p1,t1)) xs) bg 43 Just _ -> Map d (map (\(p1,t1) -> if p1 == p then (p,t) else (p1,t1)) xs) bg
50 Nothing -> Map d ((p,t):xs) bg 44 Nothing -> Map d ((p,t):xs) bg
51-- updateMap p t (Map d xs bg) = Map d (redirect p t xs) bg where
52-- redirect p t xs = (\p2 -> if p == p2 then t else xs p2)
53 45
54 -- legalMoves :: Map -> Point -> [Tile] -> [Direction] 46 -- legalMoves :: Map -> Point -> [Tile] -> [Direction]
55 legalMoves m p ts = map fst $ filter legal $ map tileDir directions where 47 legalMoves m p ts = map fst $ filter legal $ map tileDir directions where
@@ -61,7 +53,3 @@ module Fallen.Map
61 then Map d (filter outBounds xs) bg 53 then Map d (filter outBounds xs) bg
62 else Map d (filter outBounds xs ++ [((px,py), t) | px <- [x..x+w-1], py <- [y..y+h-1]]) bg where 54 else Map d (filter outBounds xs ++ [((px,py), t) | px <- [x..x+w-1], py <- [y..y+h-1]]) bg where
63 outBounds ((px,py),_) = (px < x) || (px >= (x+w)) || (py < y) || (py >= (y+h)) 55 outBounds ((px,py),_) = (px < x) || (px >= (x+w)) || (py < y) || (py >= (y+h))
64-- fillMapRect x y w h t (Map d xs bg) = Map d redirectInBounds bg where
65-- redirectInBounds = (\p -> if (inBounds p) then t else xs p)
66-- inBounds (px,py) = (px >= x) && (px < (x+w)) && (py >= y) && (py < (y+h))
67 \ No newline at end of file