56 lines
1.7 KiB
Haskell
56 lines
1.7 KiB
Haskell
{- | Flashes.
|
|
projected naming conventions: three base types of light:
|
|
glare : Draws color onto surfaces (not done)
|
|
flare : coloured light drawn in space, fixed shapes
|
|
light : removal of shadows (onto surfaces)
|
|
duration (subject to modification):
|
|
flash : short, abrupt changes in alpha
|
|
glow : continuous, potentially long, fading, slow changes in alpha
|
|
flicker : potentially long, moving, abrupt changes in alpha
|
|
-}
|
|
module Dodge.WorldEvent.Flash
|
|
( explosionFlashAt
|
|
, muzFlareAt
|
|
, ptFlicker
|
|
, flareCircleAt
|
|
) where
|
|
import Dodge.Data
|
|
import Dodge.PtFlicker
|
|
import Dodge.LightSource
|
|
import Dodge.WorldEvent.HelperParticle
|
|
--import Dodge.Default
|
|
import Picture
|
|
import Geometry
|
|
import LensHelp
|
|
|
|
import System.Random
|
|
|
|
muzFlareAt :: Color -> Point3 -> Float -> World -> World
|
|
muzFlareAt col tranv dir w = w & instantParticles .:~ theFlare
|
|
where
|
|
theFlare = Particle
|
|
{ _ptDraw = const $ setLayer BloomNoZWrite . translate3 tranv $ theShape
|
|
, _ptUpdate = ptSimpleTime 2
|
|
}
|
|
theShape = rotate dir . color col $ polygon
|
|
[ V2 0 0
|
|
, V2 a (-b)
|
|
, V2 c d
|
|
]
|
|
(a:b:c:d:_) = randomRs (2,20) (_randGen w)
|
|
|
|
flareCircleAt :: Color -> Float -> Point3 -> World -> World
|
|
flareCircleAt col alphax tranv = instantParticles .:~ Particle
|
|
{ _ptDraw = const . setLayer BloomNoZWrite . translate3 tranv
|
|
$ circleSolidCol (withAlpha 0 0) (withAlpha alphax col) 50
|
|
, _ptUpdate = ptSimpleTime 1
|
|
}
|
|
|
|
explosionFlashAt :: Point2 -> World -> World
|
|
explosionFlashAt p = tempLightSources .:~ tlsTimeRadFunPos 20 150 intensityFunc (addZ 20 p)
|
|
where
|
|
intensityFunc x
|
|
| x < 10 = 1 / (10 - fromIntegral x)
|
|
| otherwise = 1
|
|
|