Make bezier gun target on scroll
This commit is contained in:
@@ -246,21 +246,6 @@ useItem2 n (Throwable {_twFire = eff}) w = eff n w
|
||||
useItem2 _ _ w = w
|
||||
|
||||
|
||||
useItemAmmoCheck :: Int -> World -> World
|
||||
useItemAmmoCheck n w
|
||||
| hasAmmo = useItem1 n w
|
||||
| otherwise = w
|
||||
where c = _creatures w IM.! n
|
||||
hasAmmo = case _crInv c IM.! _crInvSel c of
|
||||
Weapon {_wpLoadedAmmo=0, _wpAmmoType=ammoT}
|
||||
-> case _crAmmo c M.!? ammoT of
|
||||
Just x -> x > 0
|
||||
_ -> False
|
||||
Weapon {} -> True
|
||||
_ -> False
|
||||
|
||||
|
||||
|
||||
createItemAt :: Point2 -> FloorItem -> World -> World
|
||||
createItemAt p it w = over floorItems (IM.insert i (set flItPos p
|
||||
$ set flItID i it)) w
|
||||
|
||||
@@ -381,6 +381,7 @@ data ItAttachment
|
||||
| ItFuse {_itFuseTime :: Int}
|
||||
| ItPhaseV {_itPhaseV :: Float}
|
||||
| ItMode {_itMode :: Int}
|
||||
| ItTargetPos { _itTargetPos :: Point2 }
|
||||
|
||||
data ItEffect = NoItEffect
|
||||
| ItInvEffect {_itInvEffect :: Creature -> Int -> World -> World
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -87,10 +87,6 @@ handleMouseWheelEvent w mwev =
|
||||
V2 x y | y > 0 -> Just $ wheelUpEvent w
|
||||
| y < 0 -> Just $ wheelDownEvent w
|
||||
| otherwise -> Just $ w
|
||||
-- case mouseWheelEventDirection mwev of
|
||||
-- ScrollNormal -> Just $ wheelUpEvent w
|
||||
-- ScrollFlipped -> Just $ wheelDownEvent w
|
||||
|
||||
|
||||
handleResizeEvent :: World -> WindowSizeChangedEventData -> Maybe World
|
||||
handleResizeEvent w sev = Just $ set windowX (fromIntegral x)
|
||||
|
||||
@@ -298,6 +298,7 @@ divideLine x a b = take 5000 $ map (\i -> a +.+ (i / (fromIntegral numPoints) *.
|
||||
|
||||
-- pulled the following from the haskell wiki
|
||||
-- it seems to produce an infinite loop sometimes
|
||||
-- fuck that, don't trust random code on the internet
|
||||
bresenham :: (Int,Int) -> (Int,Int) -> [(Int,Int)]
|
||||
{-# INLINE bresenham #-}
|
||||
bresenham pa@(xa,ya) pb@(xb,yb) = map maySwitch . unfoldr go $ (x1,y1,0)
|
||||
|
||||
Reference in New Issue
Block a user