trying to prepare animations
This commit is contained in:
parent
2761777ff9
commit
81abbaf91e
3 changed files with 61 additions and 28 deletions
|
@ -78,7 +78,7 @@ load = do
|
||||||
logIO Error "Failed to load image assets"
|
logIO Error "Failed to load image assets"
|
||||||
exitFailure
|
exitFailure
|
||||||
playerImgs <- loadPlayerSprite "assets/intruder.png" 64 74 nvg
|
playerImgs <- loadPlayerSprite "assets/intruder.png" 64 74 nvg
|
||||||
(zipWith (\a b -> (a, [b])) [0..] [ImgIntrE .. ImgIntrNE])
|
(zipWith (\a b -> (a, [b])) [0..] $ [ImgIntrE .. ImgIntrN] ++ [ImgIntrNE])
|
||||||
let imgs = zipWith (\a b -> (a, fromJust b)) [ImgWallAsc ..] mimgs
|
let imgs = zipWith (\a b -> (a, fromJust b)) [ImgWallAsc ..] mimgs
|
||||||
return UserData
|
return UserData
|
||||||
{ state = Menu
|
{ state = Menu
|
||||||
|
|
10
src/Test.hs
10
src/Test.hs
|
@ -56,14 +56,20 @@ loadMap = do
|
||||||
(inter, rps) <- liftIO $ placeInteriorIO mat imgmat exits gr
|
(inter, rps) <- liftIO $ placeInteriorIO mat imgmat exits gr
|
||||||
liftIO $ logIO A.Debug ("number of reachpoints: " ++ show (length rps))
|
liftIO $ logIO A.Debug ("number of reachpoints: " ++ show (length rps))
|
||||||
let nnex = Prelude.filter (\p -> pointType p /= RoomExit) rps
|
let nnex = Prelude.filter (\p -> pointType p /= RoomExit) rps
|
||||||
|
playerAnim = Animations
|
||||||
|
{ animStand = Map.fromList
|
||||||
|
(zip [NE .. N] [ImgIntrNE .. ImgIntrN])
|
||||||
|
}
|
||||||
npcposs <- placeNPCs inter mat rps gr 50 -- (length nnex)
|
npcposs <- placeNPCs inter mat rps gr 50 -- (length nnex)
|
||||||
liftIO $ A.logIO A.Debug $ "number of placed NPCs: " ++ show (length npcposs)
|
liftIO $ A.logIO A.Debug $ "number of placed NPCs: " ++ show (length npcposs)
|
||||||
(nws, _) <- liftIO $ yieldSystemT (worldState ud) $ do
|
(nws, _) <- liftIO $ yieldSystemT (worldState ud) $ do
|
||||||
void $ createEntity $ newEntity
|
createEntity $ newEntity
|
||||||
{ pos = Just (V2 20.5 20.5)
|
{ pos = Just (V2 20.5 20.5)
|
||||||
, vel = Just (V2 0 0)
|
, vel = Just (V2 0 0)
|
||||||
, player = Just ()
|
, player = Just ()
|
||||||
, rot = Just SE
|
, rot = Just SE
|
||||||
|
, anim = Just playerAnim
|
||||||
|
, animCurrFrame = Just (0, 0)
|
||||||
}
|
}
|
||||||
void $ mapM_ (\npcpos@(V2 nr nc) -> do
|
void $ mapM_ (\npcpos@(V2 nr nc) -> do
|
||||||
-- ttl <- liftIO $ randomRIO (5, 30)
|
-- ttl <- liftIO $ randomRIO (5, 30)
|
||||||
|
@ -76,6 +82,8 @@ loadMap = do
|
||||||
, velFact = Just fact
|
, velFact = Just fact
|
||||||
, rot = Just SE
|
, rot = Just SE
|
||||||
, npcState = Just (NPCStanding 0 future)
|
, npcState = Just (NPCStanding 0 future)
|
||||||
|
, anim = Just playerAnim
|
||||||
|
, animCurrFrame = Just (0, 0)
|
||||||
}
|
}
|
||||||
) npcposs
|
) npcposs
|
||||||
uu <- partSubscribe m movePlayer
|
uu <- partSubscribe m movePlayer
|
||||||
|
|
|
@ -24,6 +24,7 @@ data UserData = UserData
|
||||||
, subsystems :: Subsystems
|
, subsystems :: Subsystems
|
||||||
, assetImages :: M.Map ImgId Image
|
, assetImages :: M.Map ImgId Image
|
||||||
, assetFonts :: M.Map FontId T.Text
|
, assetFonts :: M.Map FontId T.Text
|
||||||
|
, assetAnimations :: M.Map AnimId Animation
|
||||||
, nano :: Context
|
, nano :: Context
|
||||||
, uuid :: [UUID]
|
, uuid :: [UUID]
|
||||||
, worldState :: SystemState Entity IO
|
, worldState :: SystemState Entity IO
|
||||||
|
@ -62,6 +63,7 @@ data ImgId
|
||||||
| ImgMiscTable3
|
| ImgMiscTable3
|
||||||
| ImgMiscTable4
|
| ImgMiscTable4
|
||||||
| ImgMiscTableCorner
|
| ImgMiscTableCorner
|
||||||
|
| ImgIntrNE
|
||||||
| ImgIntrE
|
| ImgIntrE
|
||||||
| ImgIntrSE
|
| ImgIntrSE
|
||||||
| ImgIntrS
|
| ImgIntrS
|
||||||
|
@ -69,7 +71,6 @@ data ImgId
|
||||||
| ImgIntrW
|
| ImgIntrW
|
||||||
| ImgIntrNW
|
| ImgIntrNW
|
||||||
| ImgIntrN
|
| ImgIntrN
|
||||||
| ImgIntrNE
|
|
||||||
deriving (Show, Eq, Ord, Enum)
|
deriving (Show, Eq, Ord, Enum)
|
||||||
|
|
||||||
isWall :: ImgId -> Bool
|
isWall :: ImgId -> Bool
|
||||||
|
@ -173,6 +174,7 @@ data Entity f = Entity
|
||||||
, obstacle :: Component f 'Field (Boundaries Double)
|
, obstacle :: Component f 'Field (Boundaries Double)
|
||||||
, player :: Component f 'Unique ()
|
, player :: Component f 'Unique ()
|
||||||
, npcState :: Component f 'Field NPCState
|
, npcState :: Component f 'Field NPCState
|
||||||
|
, anim :: Component f 'Field AnimState
|
||||||
}
|
}
|
||||||
deriving (Generic)
|
deriving (Generic)
|
||||||
|
|
||||||
|
@ -241,3 +243,26 @@ generalUnSubscribe t uu =
|
||||||
liftIO $ atomically $ modifyTVar' t (filter (`filterMsg` uu))
|
liftIO $ atomically $ modifyTVar' t (filter (`filterMsg` uu))
|
||||||
where
|
where
|
||||||
filterMsg (u, _) p = u /= p
|
filterMsg (u, _) p = u /= p
|
||||||
|
|
||||||
|
-- ANIMATIONS
|
||||||
|
|
||||||
|
data AnimId = AnimId
|
||||||
|
{ aiVariation :: Int
|
||||||
|
, aiDirection :: Direction
|
||||||
|
}
|
||||||
|
|
||||||
|
data AnimState = AnimState
|
||||||
|
{ asId :: AnimId
|
||||||
|
, asCurrentFrame :: Int
|
||||||
|
, asElapsedTime :: Double
|
||||||
|
}
|
||||||
|
|
||||||
|
data AnimPlayback
|
||||||
|
= APLoop
|
||||||
|
| APOnce
|
||||||
|
|
||||||
|
data Animation = Animation
|
||||||
|
{ animDuration :: Double
|
||||||
|
, animSprites :: [Image]
|
||||||
|
, animPLay :: AnimPlayback
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue