Further tweak jetpack

This commit is contained in:
jgk
2021-04-24 20:06:19 +02:00
parent e23e076184
commit 71795d2d9d
2 changed files with 19 additions and 14 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ startCr = defaultCreature
startInventory = IM.fromList (zip [0..20]
(
[ --jetPack
[ jetPack
--[pistol
--,blinkGun
--,spawnGun lamp
+18 -13
View File
@@ -28,11 +28,15 @@ yourControl w (f,g) cr = ( (updateUsingInput . f, g)
speed = _varMovementSpeedModifier w * equipFactor
equipFactor = product $ map equipSpeed $ IM.elems $ _crInv $ _creatures w IM.! 0
{-
Turns key presses into creature movement.
-}
wasdWithAiming :: World -> Float -> Float -> Int -> Creature -> Creature
wasdWithAiming w speed aimSpeed i cr
| (any (\it -> it ^? itIdentity == Just JetPack) $ _crInv cr) && isMoving && isAiming
&& diffAngles mouseDir (argV mov) < pi/3
= over crPos (+.+ (0.2 *.* mov))
&& diffAngles mouseDir (argV mov) < pi/2
-- = over crPos (+.+ (speed *.* mov))
= over crPos (+.+ (speed *.* unitVectorAtAngle mouseDir))
. set crDir mouseDir
$ set (crState . stance . carriage) (Boosting mov)
cr
@@ -41,7 +45,7 @@ wasdWithAiming w speed aimSpeed i cr
$ set (crState . stance . carriage) Floating
cr
| (any (\it -> it ^? itIdentity == Just JetPack) $ _crInv cr) && isMoving
= over crPos (+.+ (0.2 *.* mov))
= over crPos (+.+ (speed *.* mov))
. over crDir (flip fromMaybe dir)
$ set (crState . stance . carriage) (Boosting mov)
cr
@@ -65,16 +69,17 @@ wasdWithAiming w speed aimSpeed i cr
| otherwise
= over ( crDir) (flip fromMaybe dir)
cr
where (mov',dir') = wasdComp (view keys w) w
(mov,dir) = (rotateV (_cameraRot w) mov',fmap (_cameraRot w +) dir')
isMoving = mov' /= (0,0)
isAiming = (_posture $ _stance $ _crState cr) == Aiming
mouseDir = case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itAttachment of
Just (Just (ItScope {_scopePos = p})) -> normalizeAngle $ argV
$ p +.+ 2 / _cameraZoom w
*.* rotateV (_cameraRot w) (_mousePos w)
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
where
(mov',dir') = wasdComp (view keys w) w
(mov,dir) = (rotateV (_cameraRot w) mov',fmap (_cameraRot w +) dir')
isMoving = mov' /= (0,0)
isAiming = (_posture $ _stance $ _crState cr) == Aiming
mouseDir = case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itAttachment of
Just (Just (ItScope {_scopePos = p})) -> normalizeAngle $ argV
$ p +.+ 2 / _cameraZoom w
*.* rotateV (_cameraRot w) (_mousePos w)
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
wasdM :: World -> SDL.Scancode -> Point2