diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 7f40a7823..ef609ab4a 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -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 -- convoluted stateUpdate :: CRUpdate -> CRUpdate -stateUpdate u w (f,g) cr = - let (cr', g'') = updateMovement g cr - in case u w (f,g'') cr' of +stateUpdate u w (f,g) cr = case u w (f,g) cr of ((f',g') , maybeCr) -> ( (invSideEff cr . movementSideEff cr . deathEff . f' , g') - , fmap (stepReloading . stepItemUseCooldown . doDamage . crAutoReload) $ crOrCorpse =<< maybeCr + , fmap (stepReloading . stepItemUseCooldown . doDamage . crAutoReload . updateMovement g') $ crOrCorpse =<< maybeCr ) where - crOrCorpse cr' - | cr' ^. crHP > 0 = Just cr' + crOrCorpse cr''' + | cr''' ^. crHP > 0 = Just cr''' | otherwise = Nothing deathEff | cr ^.crHP > 0 = id @@ -135,16 +133,16 @@ weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of where cid = _crID cr -updateMovement :: StdGen -> Creature -> (Creature, StdGen) +updateMovement :: StdGen -> Creature -> Creature updateMovement g cr - | isFrictionless cr = (over crPos (+.+ momentum) $ setOldPos cr, g') - | otherwise = (updateWalkCycle $ setOldPos cr, g) + | isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr + | otherwise = updateWalkCycle $ setOldPos cr where momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr) momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum' | otherwise = momentum' momentum = momentum'' +.+ 0.01 *.* unitVectorAtAngle randAng - (randAng,g') = randomR (0,2*pi) g + (randAng,_) = randomR (0,2*pi) g isFrictionless :: Creature -> Bool isFrictionless cr = case cr ^? crStance . carriage of diff --git a/src/Dodge/Room/LongDoor.hs b/src/Dodge/Room/LongDoor.hs index cb6db1aa3..1969063af 100644 --- a/src/Dodge/Room/LongDoor.hs +++ b/src/Dodge/Room/LongDoor.hs @@ -42,10 +42,8 @@ twinSlowDoorRoom drID w h x = defaultRoom [ sPS (V2 0 (h/2)) 0 putLamp , sPS (V2 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 $ PutDoor col (not . cond) drR - , 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 0) 0 $ PutSingleDoor col cond (V2 x 1) (V2 x h) + , sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 (-x) 1) (V2 (-x) h) , sPS (V2 0 (h-5)) pi $ PutButton $ makeButton col (over worldState (M.insert (DoorNumOpen drID) True)) ] @@ -53,14 +51,9 @@ twinSlowDoorRoom drID w h x = defaultRoom } where ps = - [rectNSWE h (-2) (-w) w + [rectNSWE h 0 (-w) w ,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') col = dim $ dim $ bright red