From ed585355b1f78de15885e803138a98b75ca2b1e2 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 20 Feb 2023 21:52:22 +0000 Subject: Split entities in modules. --- src/Game/Entities/Types.hs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Game/Entities/Types.hs (limited to 'src/Game/Entities/Types.hs') diff --git a/src/Game/Entities/Types.hs b/src/Game/Entities/Types.hs new file mode 100644 index 0000000..ed609d3 --- /dev/null +++ b/src/Game/Entities/Types.hs @@ -0,0 +1,46 @@ +module Game.Entities.Types + ( Dir (..), + Type (..), + Collision, + IsBlocked, + Entities (..), + Spawn (..), + Entity (..), + ) +where + +import Data.IORef +import qualified Game.Sprites as S +import qualified Game.State as GS + +data Dir = DirRight | DirLeft deriving (Eq) + +data Type = TypePlayer | TypePickup | TypeEffect | TypeEnemy + +type Collision = Entity -> IO Bool + +type IsBlocked = Int -> Int -> Bool + +data Entities = Entities + { sprites :: S.SpriteSheet, + player :: IORef Entity, + state :: IORef GS.State, + entities :: [Entity] + } + +data Spawn = DustEffectSpawn Int Int + +data Entity = Entity + { typ :: Type, + x :: Int, + y :: Int, + delay :: Int, + frame :: Int, + jumping :: Bool, + gravity :: Int, + dir :: Dir, + sprite :: S.Sprite, + update :: Entity -> IO Entity, + destroy :: Bool, + spawns :: [Spawn] + } -- cgit v1.2.3