aboutsummaryrefslogtreecommitdiff
path: root/src/Game/Entities
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-03-02 12:54:47 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-03-02 12:54:47 +0000
commite5cbf917ad8b12b48932bc4fa13a044bc8159a74 (patch)
tree41511ca9f1447643ac921b2294f5dab8a62731e2 /src/Game/Entities
parent5dd9180606e935ee5a7c1637773fdfc3277677ca (diff)
downloadspace-plat-hs-e5cbf917ad8b12b48932bc4fa13a044bc8159a74.tar.gz
space-plat-hs-e5cbf917ad8b12b48932bc4fa13a044bc8159a74.zip
Even less IORef
Also reviewed comments and made the action to add effects more general.
Diffstat (limited to 'src/Game/Entities')
-rw-r--r--src/Game/Entities/Player.hs2
-rw-r--r--src/Game/Entities/Types.hs7
2 files changed, 5 insertions, 4 deletions
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,