This commit is contained in:
2022-02-22 22:07:55 +00:00
parent 8a7d06783d
commit 1e5f24c8a1
9 changed files with 20 additions and 49 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ bezierGun = defaultGun
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 15
}
, _itTargeting' = targetRBPress
, _itTargeting = targetRBPress
}
shootBezier :: Point2 -> Creature -> World -> World
shootBezier targetp cr w = w & particles .:~ aCurveBulAt
+4 -34
View File
@@ -89,49 +89,19 @@ targetRBPress = TargetingOnHeld
, _tgDraw = targetRBPressDraw
}
targetRBPressDraw :: Int -> Item -> Creature -> World -> Picture
targetRBPressDraw _ it _ w' = fromMaybe mempty $ do
mwp <- it ^? itTargeting' . tgPos . _Just
targetRBPressDraw _ it _ w = fromMaybe mempty $ do
mwp <- it ^? itTargeting . tgPos . _Just
return $ setLayer 1 $ color red $ onLayer InvLayer $ uncurryV translate mwp
$ rotate (_cameraRot w')
$ rotate (_cameraRot w)
$ pictures
[line [V2 x x, V2 (-x) (-x)]
,line [V2 (-x) x, V2 x (-x)]
]
where
x = 5 / _cameraZoom w'
x = 5 / _cameraZoom w
targetRBPressUpdate :: Item -> Creature -> World -> Targeting -> Targeting
targetRBPressUpdate _ _ w t
| SDL.ButtonRight `S.member` _mouseButtons w = t
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
| otherwise = t & tgPos %~ const Nothing
--rbSetTarget :: ItEffect
--rbSetTarget = ItInvEffect
-- {_itInvEffect = setTarg
-- ,_itEffectCounter = 0
-- }
-- where
-- setTarg :: ItEffect -> Creature -> Int -> World -> World
-- setTarg _ cr invid w
-- | _crInvSel cr /= invid = w
-- | SDL.ButtonRight `S.member` _mouseButtons w = w
-- & creatures . ix (_crID cr) . crInv . ix invid . itTargeting
-- %~ maybe (Just $ targetRBMousePos w) Just
-- | otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ Nothing
targetRBMousePos
:: World
-> (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
targetRBMousePos w = (f, \_ _ _ w' -> cursorPic w')
where
f _ = Just mwp
mwp = mouseWorldPos w
cursorPic w' = setLayer 1 $ color red $ onLayer InvLayer $ uncurryV translate mwp
$ rotate (_cameraRot w')
$ pictures
[line [V2 x x, V2 (-x) (-x)]
,line [V2 (-x) x, V2 x (-x)]
]
where
x = 5 / _cameraZoom w'
+5 -3
View File
@@ -1,5 +1,7 @@
module Dodge.Item.Weapon.Targeting
where
( useTargetPos
, removeItTarget
) where
import Dodge.Data
import Geometry.Data
@@ -10,9 +12,9 @@ useTargetPos
-> Creature
-> World
-> World
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting' . tgPos of
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . tgPos of
Nothing -> w
Just p -> f p cr w
removeItTarget :: Item -> Item
removeItTarget = itTargeting' . tgPos .~ Nothing
removeItTarget = itTargeting . tgPos .~ Nothing