diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-02-21 12:40:31 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-02-21 12:40:31 +0000 |
commit | 198498b3c604d55d3b54fef34c62f215ba8a2525 (patch) | |
tree | f3d7725657608cafdfc4888313f3631c14857032 /src/Game/Entities/Common.hs | |
parent | fd74ead510f4ca326e36450fa23dee0d681c296b (diff) | |
download | space-plat-hs-198498b3c604d55d3b54fef34c62f215ba8a2525.tar.gz space-plat-hs-198498b3c604d55d3b54fef34c62f215ba8a2525.zip |
New Robot enemy.
Diffstat (limited to 'src/Game/Entities/Common.hs')
-rw-r--r-- | src/Game/Entities/Common.hs | 6 |
1 files changed, 3 insertions, 3 deletions
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. |