nonuniform movement speeds for NPCs
This commit is contained in:
parent
1c9076c838
commit
8a620f742e
2 changed files with 6 additions and 1 deletions
|
@ -64,9 +64,11 @@ loadMap = do
|
||||||
}
|
}
|
||||||
void $ mapM_ (\(V2 nr nc) -> do
|
void $ mapM_ (\(V2 nr nc) -> do
|
||||||
-- ttl <- liftIO $ randomRIO (5, 30)
|
-- ttl <- liftIO $ randomRIO (5, 30)
|
||||||
|
fact <- liftIO $ randomRIO (0.5, 1.5)
|
||||||
newEntity $ defEntity
|
newEntity $ defEntity
|
||||||
{ pos = Just (V2 (nr + 0.5) (nc + 0.5))
|
{ pos = Just (V2 (nr + 0.5) (nc + 0.5))
|
||||||
, vel = Just (V2 0 0)
|
, vel = Just (V2 0 0)
|
||||||
|
, velFact = Just fact
|
||||||
, npcState = Just (NPCStanding 0)
|
, npcState = Just (NPCStanding 0)
|
||||||
}
|
}
|
||||||
) npcposs
|
) npcposs
|
||||||
|
@ -181,10 +183,12 @@ updateMap dt = do
|
||||||
emap $ do
|
emap $ do
|
||||||
without player
|
without player
|
||||||
with vel
|
with vel
|
||||||
|
with velFact
|
||||||
with pos
|
with pos
|
||||||
pos'@(V2 pr pc) <- E.get pos
|
pos'@(V2 pr pc) <- E.get pos
|
||||||
vel' <- E.get vel
|
vel' <- E.get vel
|
||||||
let npos@(V2 nr nc) = pos' + fmap (* dt) vel'
|
fact' <- E.get velFact
|
||||||
|
let npos@(V2 nr nc) = pos' + fmap (* (dt * fact')) vel'
|
||||||
dpos = npos - pos'
|
dpos = npos - pos'
|
||||||
ent = defEntity'
|
ent = defEntity'
|
||||||
{ pos = Set $ npos
|
{ pos = Set $ npos
|
||||||
|
|
|
@ -147,6 +147,7 @@ data Entity f = Entity
|
||||||
{ pos :: Component f 'Field (V2 Double)
|
{ pos :: Component f 'Field (V2 Double)
|
||||||
, gridPos :: Component f 'Field (V2 Int)
|
, gridPos :: Component f 'Field (V2 Int)
|
||||||
, vel :: Component f 'Field (V2 Double)
|
, vel :: Component f 'Field (V2 Double)
|
||||||
|
, velFact :: Component f 'Field Double
|
||||||
, rot :: Component f 'Field Direction
|
, rot :: Component f 'Field Direction
|
||||||
, obstacle :: Component f 'Field (Boundaries Double)
|
, obstacle :: Component f 'Field (Boundaries Double)
|
||||||
, player :: Component f 'Unique ()
|
, player :: Component f 'Unique ()
|
||||||
|
|
Loading…
Reference in a new issue