From 449dc21f1b48648c5e4abf1a6cace21176fa2226 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 26 Mar 2023 08:49:35 +0100 Subject: Support entities facing left Perhaps it would be better to support "custom properties" in tiled, but this is OK for now. --- src/Game/Map.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Game/Map.hs') diff --git a/src/Game/Map.hs b/src/Game/Map.hs index 3fb72f9..ea20b17 100644 --- a/src/Game/Map.hs +++ b/src/Game/Map.hs @@ -14,6 +14,7 @@ where import Control.Monad import Data.Maybe (fromMaybe, mapMaybe) +import Game.Entities.Types (Dir (..)) import qualified Game.Utils as U import SDL (($=)) import qualified SDL @@ -39,8 +40,8 @@ data Layer data Object = PlayerEntity Int Int | BatteryEntity Int Int - | SlimeEntity Int Int - | RobotEntity Int Int + | SlimeEntity Int Int Dir + | RobotEntity Int Int Dir deriving (Show, Eq, Ord) data JsonMapData = JsonMapData @@ -81,9 +82,13 @@ instance JSON Object where Just "Battery" -> BatteryEntity <$> valFromObj "x" obj <*> valFromObj "y" obj Just "Slime" -> - SlimeEntity <$> valFromObj "x" obj <*> valFromObj "y" obj + SlimeEntity <$> valFromObj "x" obj <*> valFromObj "y" obj <*> pure DirRight Just "Robot" -> - RobotEntity <$> valFromObj "x" obj <*> valFromObj "y" obj + RobotEntity <$> valFromObj "x" obj <*> valFromObj "y" obj <*> pure DirRight + Just "Slime-l" -> + SlimeEntity <$> valFromObj "x" obj <*> valFromObj "y" obj <*> pure DirLeft + Just "Robot-l" -> + RobotEntity <$> valFromObj "x" obj <*> valFromObj "y" obj <*> pure DirLeft Just (JSString (JSONString s)) -> Error $ "unsupported entity " ++ show s e -> Error $ "unsupported entity in " ++ show e readJSON _ = mzero -- cgit v1.2.3