From 9f1811975e996a3bf70c3e834a872e59c8ade984 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 14 Apr 2023 08:37:14 +0100 Subject: Load the map list from a JSON file --- src/Game/Map.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Game') 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 -- cgit v1.2.3