From 88e2522ab981b94d2d3814ed735a1a43823784f1 Mon Sep 17 00:00:00 2001 From: Ivy Date: Thu, 18 Feb 2021 23:11:24 +0100 Subject: [PATCH] Changed the map --- maps/test.map | 32 +++++++++++++++++++++++++------- src/Game.hs | 8 ++++---- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/maps/test.map b/maps/test.map index 4150943..2f0b033 100644 --- a/maps/test.map +++ b/maps/test.map @@ -1,7 +1,25 @@ -######################## -#......................# -#......................# -#......................# -#......................# -#......................# -######################## +######################### +####......#####....###### +###.........###.....##### +##....#......###....##### +##...###......##.....#### +##..######....##......### +##..######....###.....### +#...########..#####....## +#....#######..######...## +#....#####.......###....# +##...####...#.....##....# +###........######.###...# +###.......##......###...# +###...#..###.########...# +##...#######.......###..# +#....#############.#....# +#.....####.###.....##..## +#.........########.....## +##...##############....## +###...###..###.######..## +###.......##....####...## +####.#####......###...### +#..###................### +#..................###### +######################### diff --git a/src/Game.hs b/src/Game.hs index ba49b4a..55cd107 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -20,12 +20,12 @@ makeLenses ''Game newGame :: IO Game newGame = do dun <- makeDungeonFromFile "maps/test.map" - return $ Game dun (Player $ V2 1 1) + return $ Game dun (Player $ V2 1 24) runAction :: Action -> Game -> Maybe Game -runAction (Move vec) game = - if ableToMove then Just $ game & player . pos .~ newPos - else Just game +runAction (Move vec) game = Just $ if ableToMove + then game & player . pos .~ newPos + else game where ableToMove = getCell newPos (game ^. dungeon) == Empty newPos = (game ^. player . pos) + vec runAction None g = Just g