Modularise and improve step cycle
This commit is contained in:
@@ -2,6 +2,7 @@ module Dodge.Creature.State where
|
||||
import Dodge.Data
|
||||
import Dodge.Item.Data
|
||||
import Dodge.Creature.State.Data
|
||||
import Dodge.Creature.State.WalkCycle
|
||||
import Dodge.Creature.Stance.Data
|
||||
--import Dodge.Creature.Test
|
||||
import Dodge.Base
|
||||
@@ -98,9 +99,7 @@ movementSideEff cr w
|
||||
$ set randGen g
|
||||
w
|
||||
_ -> w
|
||||
| otherwise = case cr ^? crStance . carriage of
|
||||
Just (Walking x y) -> takeStep x y w
|
||||
_ -> w
|
||||
| otherwise = footstepSideEffect cr w
|
||||
where
|
||||
hasJetPack = any (\it -> it ^? itIdentity == Just JetPack) $ _crInv cr
|
||||
oldPos = _crOldPos cr
|
||||
@@ -111,11 +110,8 @@ movementSideEff cr w
|
||||
(randDir,g) = randomR (-0.5,0.5) $ _randGen w
|
||||
(randAng,_) = randomR (0,2*pi) $ _randGen w
|
||||
|
||||
crHasMoved = dist (_crPos cr) (_crOldPos cr) > 0.5
|
||||
takeStep x y | crHasMoved && x < 20 && x + y >= 20 = soundMultiFrom footor 22 3 0
|
||||
| crHasMoved && x < 80 && x + y >= 80 = soundMultiFrom footor 23 3 0
|
||||
| otherwise = id
|
||||
footor = [FootstepSound 0,FootstepSound 1]
|
||||
--crHasMoved = dist (_crPos cr) (_crOldPos cr) > 0.5
|
||||
|
||||
|
||||
invSideEff :: Creature -> World -> World
|
||||
invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
||||
@@ -136,12 +132,7 @@ weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of
|
||||
updateMovement :: StdGen -> Creature -> (Creature, StdGen)
|
||||
updateMovement g cr
|
||||
| isFrictionless cr = (over crPos (+.+ momentum) $ setOldPos cr, g')
|
||||
| otherwise = case cr ^? crStance . carriage of
|
||||
Just (Walking x y)
|
||||
-> (set (crStance . carriage) (Walking ((x+y)`mod`120) 0) $ setOldPos cr
|
||||
, g)
|
||||
_ -> (set (crStance . carriage) (Walking 0 0) $ setOldPos cr
|
||||
, g)
|
||||
| otherwise = (updateWalkCycle $ setOldPos cr, g)
|
||||
where
|
||||
momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr)
|
||||
momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum'
|
||||
|
||||
Reference in New Issue
Block a user