Fix aiming creature direction when zooming

This commit is contained in:
2022-06-05 00:51:53 +01:00
parent 8e73203db3
commit 5e144b1cd5
3 changed files with 14 additions and 9 deletions
+4 -2
View File
@@ -2,6 +2,7 @@ module Dodge.Creature.YourControl
( yourControl
) where
import Dodge.Data
import Dodge.Base.Coordinate
import Dodge.Creature.Impulse.Movement
import Dodge.Update.UsingInput
--import Dodge.Config.KeyConfig
@@ -52,8 +53,9 @@ wasdWithAiming w speed cr
isAiming = _posture (_crStance cr) == Aiming
isReloading = _posture (_crStance cr) == Reloading
mouseDir = case cr ^? crInv . ix (_crInvSel cr) . itScope . scopePos of
Just p -> normalizeAngle $ argV
$ p +.+ 2 / _cameraZoom w *.* rotateV (_cameraRot w) (_mousePos w)
Just _ -> argV $ mouseWorldPos w -.- _crPos cr
-- Just p -> normalizeAngle $ argV
-- $ p +.+ 2 / _cameraZoom w *.* rotateV (_cameraRot w) (_mousePos w)
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
wasdM :: SDL.Scancode -> Point2
+2 -2
View File
@@ -4,7 +4,7 @@ import LensHelp
zoomLongGun :: Float -> Creature -> Item -> Item
zoomLongGun x _
| x > 0 = itScope . scopeZoomChange %~ (max 10 . (+3))
| x < 0 = itScope . scopeZoomChange %~ (min (-10) . subtract 3)
| x > 0 = itScope . scopeZoomChange %~ (max 15 . (+4))
| x < 0 = itScope . scopeZoomChange %~ (min (-15) . subtract 4)
| otherwise = id
--zoomLongGun x _ = itScope . scopeZoomChange .~ round (signum x)
+8 -5
View File
@@ -81,9 +81,11 @@ updateScopeZoom w
= case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itScope . scopeZoomChange of
Just x
| x > 9 -> zoomInLongGun $ zoomInLongGun w
| x > 10 -> zoomInLongGun $ zoomInLongGun $ zoomInLongGun w
| x > 5 -> zoomInLongGun $ zoomInLongGun w
| x > 0 -> zoomInLongGun w
| x < -9 -> zoomOutLongGun $ zoomOutLongGun w
| x < -10 -> zoomOutLongGun $ zoomOutLongGun $ zoomOutLongGun w
| x < -5 -> zoomOutLongGun $ zoomOutLongGun w
| x < 0 -> zoomOutLongGun w
| otherwise -> w
_ -> w
@@ -99,10 +101,10 @@ zoomSpeed = 39/40
zoomInLongGun :: World -> World
zoomInLongGun w
| currentZoom < 8 = w
& wpPointer . itScope . scopePos .+.+~ (1-(1*zoomSpeed)) / newzoom *.* mousep
& wpPointer . itScope . scopePos .+.+~ (1-zoomSpeed) / newzoom *.* mousep
& wpPointer . itScope . scopeZoom %~ (/ zoomSpeed)
& decreaseScopeZoomChange
| otherwise = decreaseScopeZoomChange w
| otherwise = w & wpPointer . itScope . scopeZoomChange .~ 0
where
decreaseScopeZoomChange = wpPointer . itScope . scopeZoomChange -~ 1
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
@@ -117,7 +119,8 @@ zoomOutLongGun w
-- & wpPointer . itScope . scopePos .+.+~ ((1*zoomSpeed-1)) / currentZoom *.* mousep
& wpPointer . itScope . scopeZoom *~ zoomSpeed
& increaseScopeZoomChange
| otherwise = increaseScopeZoomChange w
-- | otherwise = increaseScopeZoomChange w
| otherwise = w & wpPointer . itScope . scopeZoomChange .~ 0
where
--mousep = rotateV (_cameraRot w) $ _mousePos w
increaseScopeZoomChange = wpPointer . itScope . scopeZoomChange +~ 1