Changed the map

This commit is contained in:
Ivy 2021-02-18 23:11:24 +01:00
parent d1e7fa7956
commit 88e2522ab9
2 changed files with 29 additions and 11 deletions

View File

@ -1,7 +1,25 @@
########################
#......................#
#......................#
#......................#
#......................#
#......................#
########################
#########################
####......#####....######
###.........###.....#####
##....#......###....#####
##...###......##.....####
##..######....##......###
##..######....###.....###
#...########..#####....##
#....#######..######...##
#....#####.......###....#
##...####...#.....##....#
###........######.###...#
###.......##......###...#
###...#..###.########...#
##...#######.......###..#
#....#############.#....#
#.....####.###.....##..##
#.........########.....##
##...##############....##
###...###..###.######..##
###.......##....####...##
####.#####......###...###
#..###................###
#..................######
#########################

View File

@ -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