Flash refactor
This commit is contained in:
@@ -23,7 +23,7 @@ import Control.Lens
|
||||
-- flicker : potentially long, moving, abrupt changes in alpha
|
||||
|
||||
glareAt :: Int -> Float -> Float -> Color -> Float -> Int -> Float -> Point2 -> World -> World
|
||||
glareAt t len wdth col alphay nrays rad p w = foldr (glareLine t len wdth col alphay p) w ps
|
||||
glareAt t len wdth col alphay nrays rad p w = foldr (glareLine' t len wdth col alphay p) w ps
|
||||
where ps = map ((+.+) p) $ nRaysRad nrays rad
|
||||
|
||||
sparkFlashAt :: Point2 -> World -> World
|
||||
@@ -47,20 +47,20 @@ laserGunFlashAt p =
|
||||
. glareAt 2 10 5 yellow 0.05 20 30 p
|
||||
|
||||
|
||||
glareLine :: Int -> Float -> Float -> Color -> Float -> Point2 -> Point2 -> World -> World
|
||||
glareLine t len wdth col alphay a b w = w & particles' %~ (maybeToList linePt ++)
|
||||
glareLine' :: Int -> Float -> Float -> Color -> Float -> Point2 -> Point2 -> World -> World
|
||||
glareLine' t len wdth col alphay a b w = w & particles' %~ (maybeToList linePt ++)
|
||||
where linePt :: Maybe Particle'
|
||||
linePt = glareBetween t len wdth col alphay a b w
|
||||
linePt = glareBetween t len wdth (withAlpha alphay col) a b w
|
||||
|
||||
glareBetween :: Int -> Float -> Float -> Color -> Float -> Point2 -> Point2 -> World -> Maybe Particle'
|
||||
glareBetween 0 _ _ _ _ _ _ _ = Nothing
|
||||
glareBetween t len wdth col alphay a b w
|
||||
= Just $ Particle' {_ptDraw = const $ lowLightPic len wdth col alphay a b w
|
||||
,_ptUpdate' = \ w' _ -> (w',glareBetween (t-1) len wdth col alphay a b w')
|
||||
glareBetween :: Int -> Float -> Float -> Color -> Point2 -> Point2 -> World -> Maybe Particle'
|
||||
glareBetween 0 _ _ _ _ _ _ = Nothing
|
||||
glareBetween t len wdth col a b w
|
||||
= Just $ Particle' {_ptDraw = const $ lowLightPic len wdth col a b w
|
||||
,_ptUpdate' = \ w' _ -> (w',glareBetween (t-1) len wdth col a b w')
|
||||
}
|
||||
|
||||
lowLightPic :: Float -> Float -> Color -> Float -> Point2 -> Point2 -> World -> Picture
|
||||
lowLightPic len wdth col alphay a b w
|
||||
lowLightPic :: Float -> Float -> Color -> Point2 -> Point2 -> World -> Picture
|
||||
lowLightPic len wdth col a b w
|
||||
= case thingsHitLongLine a b w of
|
||||
((p, E3x2 wall):_)
|
||||
-> setCol . lineOfThickness wdth $ [p +.+ x, p -.- x]
|
||||
@@ -71,7 +71,7 @@ lowLightPic len wdth col alphay a b w
|
||||
$ thickArc 0 (pi/2) (_crRad cr) wdth
|
||||
where cp = _crPos cr
|
||||
_ -> blank
|
||||
where setCol = color (withAlpha alphay col) . setDepth (-0.5) . setLayer 2
|
||||
where setCol = color col . setDepth (-0.5) . setLayer 2
|
||||
|
||||
flashFlareAt :: Color -> Float -> Point2 -> Particle'
|
||||
flashFlareAt col alphax (x,y) =
|
||||
@@ -88,11 +88,11 @@ explosionFlashAt p = over tempLightSources ((:) $ tLightFade 20 150 intensityFu
|
||||
| x < 10 = 1 / (10 - fromIntegral x)
|
||||
| otherwise = 1
|
||||
|
||||
flameGlareAt = glareAt 2 10 5 orange 0.05 8 50
|
||||
flameGlareAt = glareAt 1 10 5 orange 0.05 8 40
|
||||
|
||||
lowLightDirected :: Color -> Float -> Point2 -> Point2 -> [Float] -> World -> World
|
||||
lowLightDirected col alpha a b angles w
|
||||
= foldr (\angle w' -> glareLine 2 10 5 col alpha a (a +.+ rotateV angle b) w') w angles
|
||||
= foldr (\angle w' -> glareLine' 2 10 5 col alpha a (a +.+ rotateV angle b) w') w angles
|
||||
|
||||
|
||||
muzzleFlashAt :: Point2 -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user