Make bezier gun target on scroll

This commit is contained in:
2021-03-16 11:33:47 +01:00
parent 24aede4cac
commit 97fd7f5576
6 changed files with 23 additions and 27 deletions
+18 -6
View File
@@ -109,6 +109,7 @@ autoGun = defaultGun
, _wpSpread = autogunSpread
, _wpRange = 20
, _itHammer = NoHammer
-- , _itHammer = HammerUp
, _itFloorPict = onLayer FlItLayer $ color red $ pictures [polygon [(-4,-4),(-4,4),(4,4),(4,-4)]]
, _itAmount = 1
, _itMaxStack = 1
@@ -335,11 +336,19 @@ launcher = defaultGun
, _itHammer = NoHammer
, _itEffect = NoItEffect
}
bezierGun = defaultGun
bezierGun = defaultAutoGun
{ _itName = "B-GUN"
, _wpFire = bezierControl'
, _wpFire = bezierShoot
, _itAttachment = Nothing
, _itScrollUp = removeItAttachment 0
, _itScrollDown = removeItAttachment 0
}
removeItAttachment :: Int -> Int -> World -> World
removeItAttachment i _ w = w & creatures . ix i . crInv . ix itRef . itAttachment .~ Nothing
where cr = _creatures w IM.! i
itRef = _crInvSel cr
remoteLauncher = defaultGun
{ _itName = "ROCKO-REM"
, _itIdentity = RemoteLauncher
@@ -1426,14 +1435,17 @@ bezierControl targetp cid w = resetGun $ shootWithSound 0 (mkBezierBul startp co
startp = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
resetGun = set (creatures . ix cid . crInv . ix j . wpFire) $ bezierTarget
bezierControl' :: Int -> World -> World
bezierControl' cid w = shootWithSound 0 (mkBezierBul startp controlp controlp) cid w
bezierShoot :: Int -> World -> World
bezierShoot cid w = case w ^? creatures . ix cid . crInv . ix itRef . itAttachment of
Just (Just (ItTargetPos targetp)) -> shootWithSound 0 (mkBezierBul startp controlp targetp) cid w
_ -> w & creatures . ix cid . crInv . ix itRef . itAttachment .~ Just (ItTargetPos controlp)
where
j = _crInvSel $ _creatures w IM.! cid
controlp = _crPos cr +.+ (20,20)
controlp = mouseWorldPos w
cr = _creatures w IM.! cid
dir = _crDir cr
startp = _crPos cr +.+ (11,11)
startp = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
itRef = _crInvSel cr
mkBezierBul :: Point2 -> Point2 -> Point2 -> Int -> World -> World
mkBezierBul startp controlp targetp cid w = over particles' (bbul :) w
+3 -2
View File
@@ -249,6 +249,7 @@ aCurveBulAt maycid col pos control targ hiteff width = Bul'
, _btTimer' = 100
, _btHitEffect' = hiteff
}
where f i = g $ (100 - fromIntegral i) / 10
g x = map (bf . (+ x)) [0,0.01..0.09]
where f i = g $ (100 - fromIntegral i) / den
g x = map (bf . (+ x)) [0,1 / (den * 10)..9 / (den * 10)]
bf = bQuadToF (pos,control,targ)
den = 20