diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-02-09 23:25:05 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-02-09 23:25:05 +0000 |
commit | 6e48bd38850f6326fe435ff87af3ca14e6707379 (patch) | |
tree | 6db157869c0df517e7b0629d0445bbf418f43a3b /src/Game/Map.hs | |
parent | 84057b11507a1434a9f189bca2fdb71df294c572 (diff) | |
download | space-plat-hs-6e48bd38850f6326fe435ff87af3ca14e6707379.tar.gz space-plat-hs-6e48bd38850f6326fe435ff87af3ca14e6707379.zip |
Spawn objects
For now only the Player.
Diffstat (limited to 'src/Game/Map.hs')
-rw-r--r-- | src/Game/Map.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Game/Map.hs b/src/Game/Map.hs index a1c7e84..b4d848e 100644 --- a/src/Game/Map.hs +++ b/src/Game/Map.hs @@ -1,5 +1,7 @@ module Game.Map ( Map, + MapObject (..), + objects, load, render, isBlocked, @@ -28,6 +30,7 @@ data Layer {name :: String, objects :: [MapObject]} deriving (Show) +-- | The object types in the map. data MapObject = PlayerEntity Int Int deriving (Show) data JsonMapData = JsonMapData @@ -130,6 +133,10 @@ isBlocked :: Map -> Int -> Int -> Bool isBlocked (Map (MapData mapWidth _ ts _ blocked _) _) x y = blocked !! ((x `div` ts.width) + (y `div` ts.height) * mapWidth) >= ts.firstGid +-- | Returns the objects in the map. +objects :: Map -> [MapObject] +objects (Map md _) = md.objects + -- | Renders a map. render :: SDL.Renderer -> Map -> IO () render renderer (Map mapData tex) = do |