Minor changes, commit before playing with creature update
This commit is contained in:
@@ -39,17 +39,15 @@ meleeCooldown u w (f,g) cr = u w (f,g) $ cr & crMeleeCooldown . _Just %~ (max 0
|
|||||||
-- the whole of this update cycle could do with a rethink, it is becoming
|
-- the whole of this update cycle could do with a rethink, it is becoming
|
||||||
-- convoluted
|
-- convoluted
|
||||||
stateUpdate :: CRUpdate -> CRUpdate
|
stateUpdate :: CRUpdate -> CRUpdate
|
||||||
stateUpdate u w (f,g) cr =
|
stateUpdate u w (f,g) cr = case u w (f,g) cr of
|
||||||
let (cr', g'') = updateMovement g cr
|
|
||||||
in case u w (f,g'') cr' of
|
|
||||||
((f',g') , maybeCr) ->
|
((f',g') , maybeCr) ->
|
||||||
( (invSideEff cr . movementSideEff cr . deathEff . f'
|
( (invSideEff cr . movementSideEff cr . deathEff . f'
|
||||||
, g')
|
, g')
|
||||||
, fmap (stepReloading . stepItemUseCooldown . doDamage . crAutoReload) $ crOrCorpse =<< maybeCr
|
, fmap (stepReloading . stepItemUseCooldown . doDamage . crAutoReload . updateMovement g') $ crOrCorpse =<< maybeCr
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
crOrCorpse cr'
|
crOrCorpse cr'''
|
||||||
| cr' ^. crHP > 0 = Just cr'
|
| cr''' ^. crHP > 0 = Just cr'''
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
deathEff
|
deathEff
|
||||||
| cr ^.crHP > 0 = id
|
| cr ^.crHP > 0 = id
|
||||||
@@ -135,16 +133,16 @@ weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of
|
|||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
|
|
||||||
updateMovement :: StdGen -> Creature -> (Creature, StdGen)
|
updateMovement :: StdGen -> Creature -> Creature
|
||||||
updateMovement g cr
|
updateMovement g cr
|
||||||
| isFrictionless cr = (over crPos (+.+ momentum) $ setOldPos cr, g')
|
| isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr
|
||||||
| otherwise = (updateWalkCycle $ setOldPos cr, g)
|
| otherwise = updateWalkCycle $ setOldPos cr
|
||||||
where
|
where
|
||||||
momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr)
|
momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr)
|
||||||
momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum'
|
momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum'
|
||||||
| otherwise = momentum'
|
| otherwise = momentum'
|
||||||
momentum = momentum'' +.+ 0.01 *.* unitVectorAtAngle randAng
|
momentum = momentum'' +.+ 0.01 *.* unitVectorAtAngle randAng
|
||||||
(randAng,g') = randomR (0,2*pi) g
|
(randAng,_) = randomR (0,2*pi) g
|
||||||
|
|
||||||
isFrictionless :: Creature -> Bool
|
isFrictionless :: Creature -> Bool
|
||||||
isFrictionless cr = case cr ^? crStance . carriage of
|
isFrictionless cr = case cr ^? crStance . carriage of
|
||||||
|
|||||||
@@ -42,10 +42,8 @@ twinSlowDoorRoom drID w h x = defaultRoom
|
|||||||
[ sPS (V2 0 (h/2)) 0 putLamp
|
[ sPS (V2 0 (h/2)) 0 putLamp
|
||||||
, sPS (V2 25 5) 0 putLamp
|
, sPS (V2 25 5) 0 putLamp
|
||||||
, sPS (V2 (negate 25) 5) 0 putLamp
|
, sPS (V2 (negate 25) 5) 0 putLamp
|
||||||
--, sPS (V2 0 0) 0 $ PutDoor col (not . cond) drL
|
, sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 x 1) (V2 x h)
|
||||||
--, sPS (V2 0 0) 0 $ PutDoor col (not . cond) drR
|
, sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 (-x) 1) (V2 (-x) h)
|
||||||
, sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 x 0) (V2 x h)
|
|
||||||
, sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 (-x) 0) (V2 (-x) h)
|
|
||||||
, sPS (V2 0 (h-5)) pi $ PutButton $ makeButton col
|
, sPS (V2 0 (h-5)) pi $ PutButton $ makeButton col
|
||||||
(over worldState (M.insert (DoorNumOpen drID) True))
|
(over worldState (M.insert (DoorNumOpen drID) True))
|
||||||
]
|
]
|
||||||
@@ -53,14 +51,9 @@ twinSlowDoorRoom drID w h x = defaultRoom
|
|||||||
}
|
}
|
||||||
where
|
where
|
||||||
ps =
|
ps =
|
||||||
[rectNSWE h (-2) (-w) w
|
[rectNSWE h 0 (-w) w
|
||||||
,rectNSWE 20 (-h) (negate x) x
|
,rectNSWE 20 (-h) (negate x) x
|
||||||
]
|
]
|
||||||
drL = fmap ((\h' -> (V2 x (-h'),V2 x (h-h'))) . (* h) . (/ fromIntegral nDrp) . fromIntegral)
|
|
||||||
[0..nDrp]
|
|
||||||
drR = fmap ((\h' -> (V2 (-x) (-h'),V2 (-x) (h-h'))) . (* h) . (/ fromIntegral nDrp) . fromIntegral)
|
|
||||||
[0..nDrp]
|
|
||||||
nDrp = ceiling h :: Int
|
|
||||||
cond w' = or $ M.lookup (DoorNumOpen drID) (_worldState w')
|
cond w' = or $ M.lookup (DoorNumOpen drID) (_worldState w')
|
||||||
col = dim $ dim $ bright red
|
col = dim $ dim $ bright red
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user