Tweak movement
This commit is contained in:
@@ -33,19 +33,17 @@ wasdWithAiming
|
|||||||
-> Creature
|
-> Creature
|
||||||
-> Creature
|
-> Creature
|
||||||
wasdWithAiming w speed i cr
|
wasdWithAiming w speed i cr
|
||||||
| isAiming = set crDir mouseDir $ crMvBy (speed *.* mov) cr
|
| isAiming = set crDir mouseDir $ theMovement cr
|
||||||
| isMoving = crMvAbsolute (speed *.* movAbs) $ turnAction cr
|
| otherwise = theTurn $ theMovement cr
|
||||||
-- | isMoving = crMvAbsolute (speed *.* movAbs) cr
|
|
||||||
-- | isMoving = crMvForward speed $ over crDir (`fromMaybe` dir) cr
|
|
||||||
| otherwise = cr
|
|
||||||
where
|
where
|
||||||
(mov',dir') = wasdComp (view keys w) w
|
theMovement
|
||||||
dir = fmap (_cameraRot w +) dir'
|
| movDir == (0,0) = id
|
||||||
turnAction cr' = maybe cr' (\d -> creatureTurnTowardDir d 0.2 cr') dir
|
| otherwise = crMvAbsolute (speed *.* movAbs) . set crMvDir dir
|
||||||
movAbs = rotateV (_cameraRot w) mov'
|
theTurn cr' = creatureTurnTowardDir (_crMvDir cr') 0.2 cr'
|
||||||
mov = rotateV (negate $ _crDir cr - _cameraRot w) mov'
|
movDir = wasdDir w
|
||||||
|
dir = _cameraRot w + argV movDir
|
||||||
|
movAbs = rotateV (_cameraRot w) $ normalizeV movDir
|
||||||
isAiming = _posture (_crStance cr) == Aiming
|
isAiming = _posture (_crStance cr) == Aiming
|
||||||
isMoving = mov' /= (0,0)
|
|
||||||
mouseDir = case w ^? creatures . ix i . crInv . ix (_crInvSel (_creatures w IM.! i))
|
mouseDir = case w ^? creatures . ix i . crInv . ix (_crInvSel (_creatures w IM.! i))
|
||||||
. itAttachment of
|
. itAttachment of
|
||||||
Just (Just ItScope{_scopePos = p}) -> normalizeAngle $ argV
|
Just (Just ItScope{_scopePos = p}) -> normalizeAngle $ argV
|
||||||
@@ -61,6 +59,9 @@ wasdM w scancode
|
|||||||
| scancode == moveLeftKey (_keyConfig w) = (-1, 0)
|
| scancode == moveLeftKey (_keyConfig w) = (-1, 0)
|
||||||
wasdM _ _ = (0,0)
|
wasdM _ _ = (0,0)
|
||||||
|
|
||||||
|
wasdDir :: World -> Point2
|
||||||
|
wasdDir w = foldr ((+.+) . wasdM w) (0,0) $ _keys w
|
||||||
|
|
||||||
wasdComp :: S.Set SDL.Scancode -> World -> (Point2,Maybe Float)
|
wasdComp :: S.Set SDL.Scancode -> World -> (Point2,Maybe Float)
|
||||||
wasdComp ks w = f $ foldr ( (+.+) . wasdM w ) (0,0) ks
|
wasdComp ks w = f $ foldr ( (+.+) . wasdM w ) (0,0) ks
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pictureWeaponOnAim p cr posInInv
|
|||||||
| isSelected && _posture (_crStance cr) == Aiming
|
| isSelected && _posture (_crStance cr) == Aiming
|
||||||
= onLayer PtLayer drawnWep
|
= onLayer PtLayer drawnWep
|
||||||
| isSelected && isOneHand
|
| isSelected && isOneHand
|
||||||
= onLayerL [levLayer CrLayer, -3] holsteredOneHandWep
|
= onLayerL [levLayer CrLayer, -5] holsteredOneHandWep
|
||||||
| isSelected
|
| isSelected
|
||||||
= onLayerL [levLayer CrLayer, -3] holsteredWep
|
= onLayerL [levLayer CrLayer, -3] holsteredWep
|
||||||
| otherwise = blank
|
| otherwise = blank
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import Dodge.Render.MenuScreen
|
|||||||
import Geometry
|
import Geometry
|
||||||
import Picture
|
import Picture
|
||||||
|
|
||||||
|
--import Dodge.Creature.YourControl
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
@@ -47,7 +49,7 @@ customMouseCursor w =
|
|||||||
testPic :: World -> [Picture]
|
testPic :: World -> [Picture]
|
||||||
testPic w =
|
testPic w =
|
||||||
[ setDepth (-1) . translate 0 0.8
|
[ setDepth (-1) . translate 0 0.8
|
||||||
. scale 0.001 0.001 . text . show $ _cameraRot w
|
. scale 0.001 0.001 . text . show $ _crMvDir $ you w
|
||||||
]
|
]
|
||||||
|
|
||||||
crDraw :: World -> Creature -> Picture
|
crDraw :: World -> Creature -> Picture
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ normalizeV p = (1 / magV p) *.* p
|
|||||||
{- | Angle between two vectors. Always positive. -}
|
{- | Angle between two vectors. Always positive. -}
|
||||||
angleVV :: Point2 -> Point2 -> Float
|
angleVV :: Point2 -> Point2 -> Float
|
||||||
{-# INLINE angleVV #-}
|
{-# INLINE angleVV #-}
|
||||||
angleVV a b =
|
angleVV a b
|
||||||
|
| a == b = 0
|
||||||
|
| otherwise =
|
||||||
let ma = magV a
|
let ma = magV a
|
||||||
mb = magV b
|
mb = magV b
|
||||||
d = a `dotV` b
|
d = a `dotV` b
|
||||||
|
|||||||
Reference in New Issue
Block a user