From 198498b3c604d55d3b54fef34c62f215ba8a2525 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 21 Feb 2023 12:40:31 +0000 Subject: New Robot enemy. --- src/Game/Entities/Common.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Game/Entities/Common.hs') diff --git a/src/Game/Entities/Common.hs b/src/Game/Entities/Common.hs index f72c33a..2a0c6f1 100644 --- a/src/Game/Entities/Common.hs +++ b/src/Game/Entities/Common.hs @@ -28,13 +28,13 @@ frameLimit e = S.frameCount e.sprite (toSpriteSet e.dir) -- | Collision detection of player vs entity. -- -- The player's head won't register, this is necessary to avoid hitting things on a platform above when jumping. -collision :: IORef Entity -> Collision -collision playerRef other = do +collision :: IORef Entity -> Int -> Collision +collision playerRef otherHeight other = do player <- readIORef playerRef pure $ player.x + 4 < other.x + 12 && other.x + 4 < player.x + 12 - && player.y + 12 < other.y + 16 + && player.y + otherHeight - 4 < other.y + otherHeight && other.y + 4 < player.y + 24 -- | Update game state to reflect that the player was hit by an enemy. -- cgit v1.2.3