From b61cbb00b0e983fd79f25b4750025030e8fb035b Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 14 Feb 2023 07:44:41 +0000 Subject: Adjusted collision, draw player last --- src/Game/Entities.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Game') 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 = -- cgit v1.2.3