aboutsummaryrefslogtreecommitdiff
path: root/src/Game
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-04-14 08:37:14 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-04-14 08:37:14 +0100
commit9f1811975e996a3bf70c3e834a872e59c8ade984 (patch)
tree22f5cd683e9c353fb73929eaab2b9d35cd8296b0 /src/Game
parent35d0d3911f43aca4eb34f785cdf1ad63e60863e7 (diff)
downloadspace-plat-hs-9f1811975e996a3bf70c3e834a872e59c8ade984.tar.gz
space-plat-hs-9f1811975e996a3bf70c3e834a872e59c8ade984.zip
Load the map list from a JSON file
Diffstat (limited to 'src/Game')
-rw-r--r--src/Game/Map.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Game/Map.hs b/src/Game/Map.hs
index ea20b17..9616971 100644
--- a/src/Game/Map.hs
+++ b/src/Game/Map.hs
@@ -3,6 +3,7 @@ module Game.Map
Object (..),
objects,
totalBatteries,
+ loadMapList,
load,
render,
isBlocked,
@@ -117,6 +118,14 @@ data Viewport = Viewport Int Int Int Int
data Map = Map MapData SDL.Texture
+-- | Loads a list of maps from JSON file.
+loadMapList :: String -> IO [String]
+loadMapList filename = do
+ d <- readFile filename
+ case decode d :: Result [String] of
+ Ok s -> pure s
+ Error e -> error e
+
-- | Loads a map from a JSON file.
load :: String -> SDL.Texture -> IO Map
load filename tex = do