Unify curve bullets with straight

This commit is contained in:
jgk
2021-03-25 03:06:37 +01:00
parent bc5ad33652
commit 31988e024b
5 changed files with 64 additions and 119 deletions
+1 -1
View File
@@ -374,7 +374,7 @@ mkBezierBul :: Point2 -> Point2 -> Point2 -> Int -> World -> World
mkBezierBul startp controlp targetp cid w = over particles' (bbul :) w
where
bbul = aCurveBulAt (Just cid) white startp (controlp +.+ randPos) (targetp +.+ randPos')
(destroyOnImpact bulHitCr' bulHitWall' bulHitFF') 5
(passThroughAll bulHitCr' bulHitWall' bulHitFF') 5
(randPos,randPos') = flip evalState (_randGen w)
$ do a <- randInCirc 10
b <- randInCirc 20
+4 -5
View File
@@ -237,7 +237,7 @@ aGenBulAt' maycid col pos vel hiteff width = Bul'
aCurveBulAt :: Maybe Int -> Color -> Point2 -> Point2 -> Point2 -> HitEffect -> Float -> Particle'
aCurveBulAt maycid col pos control targ hiteff width = Bul'
{ _ptDraw = drawBul
, _ptUpdate' = mvBulletTrajectory f
, _ptUpdate' = \w -> mvGenBullet' w . setVel
, _btVel' = (0,0)
, _btColor' = col
, _btTrail' = [pos]
@@ -246,7 +246,6 @@ aCurveBulAt maycid col pos control targ hiteff width = Bul'
, _btTimer' = 100
, _btHitEffect' = hiteff
}
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
where
setVel pt = pt & btVel' .~ bf (fromIntegral $ _btTimer' pt - 1) -.- bf (fromIntegral $ _btTimer' pt)
bf t = bQuadToF (pos,control,targ) $ (100 - t) * 0.05