diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-02-14 07:44:41 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-02-14 07:44:41 +0000 |
commit | b61cbb00b0e983fd79f25b4750025030e8fb035b (patch) | |
tree | fff3febbc247b892e99f684d5ba49c4ffc32aed3 /src | |
parent | 04130b1d7c3a13e0c86d152e4c17645071920da2 (diff) | |
download | space-plat-hs-b61cbb00b0e983fd79f25b4750025030e8fb035b.tar.gz space-plat-hs-b61cbb00b0e983fd79f25b4750025030e8fb035b.zip |
Adjusted collision, draw player last
Diffstat (limited to 'src')
-rw-r--r-- | src/Game/Entities.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index dca8d01..0860d49 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -67,7 +67,11 @@ frameLimit :: Entity -> Int frameLimit e = S.frameCount e.sprite (toSpriteSet e.dir) collision :: Entity -> Entity -> Bool -collision a b = a.x < b.x + 16 && b.x < a.x + 16 && a.y < b.y + 16 && b.y < a.y + 16 +collision player other = + player.x + 4 < other.x + 12 + && other.x + 4 < player.x + 12 + && player.y + 12 < other.y + 16 + && other.y + 4 < player.y + 24 mkEntities :: S.SpriteSheet -> M.Map -> IORef C.Controls -> IO Entities mkEntities sprites m controls = do @@ -100,7 +104,7 @@ updateAll es = do render :: SDL.Renderer -> Entities -> IO () render renderer es = do - traverse_ renderOne es.entities + traverse_ renderOne (reverse es.entities) where renderOne :: Entity -> IO () renderOne e = |