Fix aiming creature direction when zooming
This commit is contained in:
@@ -2,6 +2,7 @@ module Dodge.Creature.YourControl
|
|||||||
( yourControl
|
( yourControl
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Base.Coordinate
|
||||||
import Dodge.Creature.Impulse.Movement
|
import Dodge.Creature.Impulse.Movement
|
||||||
import Dodge.Update.UsingInput
|
import Dodge.Update.UsingInput
|
||||||
--import Dodge.Config.KeyConfig
|
--import Dodge.Config.KeyConfig
|
||||||
@@ -52,8 +53,9 @@ wasdWithAiming w speed cr
|
|||||||
isAiming = _posture (_crStance cr) == Aiming
|
isAiming = _posture (_crStance cr) == Aiming
|
||||||
isReloading = _posture (_crStance cr) == Reloading
|
isReloading = _posture (_crStance cr) == Reloading
|
||||||
mouseDir = case cr ^? crInv . ix (_crInvSel cr) . itScope . scopePos of
|
mouseDir = case cr ^? crInv . ix (_crInvSel cr) . itScope . scopePos of
|
||||||
Just p -> normalizeAngle $ argV
|
Just _ -> argV $ mouseWorldPos w -.- _crPos cr
|
||||||
$ p +.+ 2 / _cameraZoom w *.* rotateV (_cameraRot w) (_mousePos w)
|
-- Just p -> normalizeAngle $ argV
|
||||||
|
-- $ p +.+ 2 / _cameraZoom w *.* rotateV (_cameraRot w) (_mousePos w)
|
||||||
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
|
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
|
||||||
|
|
||||||
wasdM :: SDL.Scancode -> Point2
|
wasdM :: SDL.Scancode -> Point2
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import LensHelp
|
|||||||
|
|
||||||
zoomLongGun :: Float -> Creature -> Item -> Item
|
zoomLongGun :: Float -> Creature -> Item -> Item
|
||||||
zoomLongGun x _
|
zoomLongGun x _
|
||||||
| x > 0 = itScope . scopeZoomChange %~ (max 10 . (+3))
|
| x > 0 = itScope . scopeZoomChange %~ (max 15 . (+4))
|
||||||
| x < 0 = itScope . scopeZoomChange %~ (min (-10) . subtract 3)
|
| x < 0 = itScope . scopeZoomChange %~ (min (-15) . subtract 4)
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
--zoomLongGun x _ = itScope . scopeZoomChange .~ round (signum x)
|
--zoomLongGun x _ = itScope . scopeZoomChange .~ round (signum x)
|
||||||
|
|||||||
@@ -81,9 +81,11 @@ updateScopeZoom w
|
|||||||
= case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
= case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||||
. itScope . scopeZoomChange of
|
. itScope . scopeZoomChange of
|
||||||
Just x
|
Just x
|
||||||
| x > 9 -> zoomInLongGun $ zoomInLongGun w
|
| x > 10 -> zoomInLongGun $ zoomInLongGun $ zoomInLongGun w
|
||||||
|
| x > 5 -> zoomInLongGun $ zoomInLongGun w
|
||||||
| x > 0 -> 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
|
| x < 0 -> zoomOutLongGun w
|
||||||
| otherwise -> w
|
| otherwise -> w
|
||||||
_ -> w
|
_ -> w
|
||||||
@@ -99,10 +101,10 @@ zoomSpeed = 39/40
|
|||||||
zoomInLongGun :: World -> World
|
zoomInLongGun :: World -> World
|
||||||
zoomInLongGun w
|
zoomInLongGun w
|
||||||
| currentZoom < 8 = w
|
| currentZoom < 8 = w
|
||||||
& wpPointer . itScope . scopePos .+.+~ (1-(1*zoomSpeed)) / newzoom *.* mousep
|
& wpPointer . itScope . scopePos .+.+~ (1-zoomSpeed) / newzoom *.* mousep
|
||||||
& wpPointer . itScope . scopeZoom %~ (/ zoomSpeed)
|
& wpPointer . itScope . scopeZoom %~ (/ zoomSpeed)
|
||||||
& decreaseScopeZoomChange
|
& decreaseScopeZoomChange
|
||||||
| otherwise = decreaseScopeZoomChange w
|
| otherwise = w & wpPointer . itScope . scopeZoomChange .~ 0
|
||||||
where
|
where
|
||||||
decreaseScopeZoomChange = wpPointer . itScope . scopeZoomChange -~ 1
|
decreaseScopeZoomChange = wpPointer . itScope . scopeZoomChange -~ 1
|
||||||
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
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 . scopePos .+.+~ ((1*zoomSpeed-1)) / currentZoom *.* mousep
|
||||||
& wpPointer . itScope . scopeZoom *~ zoomSpeed
|
& wpPointer . itScope . scopeZoom *~ zoomSpeed
|
||||||
& increaseScopeZoomChange
|
& increaseScopeZoomChange
|
||||||
| otherwise = increaseScopeZoomChange w
|
-- | otherwise = increaseScopeZoomChange w
|
||||||
|
| otherwise = w & wpPointer . itScope . scopeZoomChange .~ 0
|
||||||
where
|
where
|
||||||
--mousep = rotateV (_cameraRot w) $ _mousePos w
|
--mousep = rotateV (_cameraRot w) $ _mousePos w
|
||||||
increaseScopeZoomChange = wpPointer . itScope . scopeZoomChange +~ 1
|
increaseScopeZoomChange = wpPointer . itScope . scopeZoomChange +~ 1
|
||||||
|
|||||||
Reference in New Issue
Block a user