From e5cbf917ad8b12b48932bc4fa13a044bc8159a74 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 2 Mar 2023 12:54:47 +0000 Subject: Even less IORef Also reviewed comments and made the action to add effects more general. --- src/Game/Entities/Player.hs | 2 +- src/Game/Entities/Types.hs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Game/Entities') diff --git a/src/Game/Entities/Player.hs b/src/Game/Entities/Player.hs index 87e8a7a..a69799b 100644 --- a/src/Game/Entities/Player.hs +++ b/src/Game/Entities/Player.hs @@ -48,7 +48,7 @@ updateVertical isBlocked jump down e -- make jumping easier with "Coyote time" || (e.gravity /= gravityOff && (e.gravity < gravityDown || e.gravity > jumpLimit)) = e - | not down = e {jumping = True, gravity = gravityUp, frame = jumpFrame, actions = [ActionAddDustEffect e.x (e.y + 8)]} + | not down = e {jumping = True, gravity = gravityUp, frame = jumpFrame, actions = [ActionAddEffect e.x (e.y + 8) "dust"]} -- go down a 8 pixel tall platform; not ideal to have these values hardcoded here -- but to be fair, the player height/width is hardcoded as well | down diff --git a/src/Game/Entities/Types.hs b/src/Game/Entities/Types.hs index e22032b..dce4ffa 100644 --- a/src/Game/Entities/Types.hs +++ b/src/Game/Entities/Types.hs @@ -11,7 +11,6 @@ where import Data.IORef import qualified Game.Sprites as S -import qualified Game.State as GS data Dir = DirRight | DirLeft | Dying deriving (Eq) @@ -24,11 +23,13 @@ type IsBlocked = Int -> Int -> Bool data Entities = Entities { sprites :: S.SpriteSheet, player :: IORef Entity, - state :: IORef GS.State, entities :: [Entity] } -data Action = ActionAddDustEffect Int Int | ActionAddBattery | ActionHitPlayer deriving (Show) +-- | The effect name must match the sprite name in the spritesheet. +type EffectName = String + +data Action = ActionAddEffect Int Int EffectName | ActionAddBattery | ActionHitPlayer data Entity = Entity { typ :: Type, -- cgit v1.2.3