diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-02-13 21:58:24 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-02-13 21:58:24 +0000 |
commit | 2d182c1f9c80a1e1ffb232bc6e17980cb3a64cf5 (patch) | |
tree | 3e6a2b49a5fddd3d421a83f155de255b71560159 /src/Game/Map.hs | |
parent | cfc5b71c86a4927fa8d2294fce5e8b8264b4a3ca (diff) | |
download | space-plat-hs-2d182c1f9c80a1e1ffb232bc6e17980cb3a64cf5.tar.gz space-plat-hs-2d182c1f9c80a1e1ffb232bc6e17980cb3a64cf5.zip |
Pickups WIP
TODO: collision
Diffstat (limited to 'src/Game/Map.hs')
-rw-r--r-- | src/Game/Map.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Game/Map.hs b/src/Game/Map.hs index b79ba14..3855d16 100644 --- a/src/Game/Map.hs +++ b/src/Game/Map.hs @@ -31,7 +31,10 @@ data Layer deriving (Show) -- | The object types in the map. -data Object = PlayerEntity Int Int deriving (Show) +data Object + = PlayerEntity Int Int + | BatteryEntity Int Int + deriving (Show) data JsonMapData = JsonMapData { width :: Int, @@ -68,6 +71,8 @@ instance JSON Object where case get_field obj "name" of Just "Player" -> PlayerEntity <$> valFromObj "x" obj <*> valFromObj "y" obj + Just "Battery" -> + BatteryEntity <$> valFromObj "x" obj <*> valFromObj "y" obj Just (JSString (JSONString s)) -> Error $ "unsupported entity " ++ show s e -> Error $ "unsupported entity in " ++ show e readJSON _ = mzero |