{- | 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, flareCircleAt, ) where import Dodge.Data.World import Dodge.LightSource import Control.Monad import Geometry import LensHelp import Picture import System.Random import Control.Monad.Trans.State.Strict muzFlareAt :: Color -> Point3 -> Float -> World -> World muzFlareAt col tranv dir w = w & randGen .~ g & cWorld . lWorld . flares .:~ MuzFlare { _flarePoly = map (rotateV dir) [ V2 0 0 , V2 a (- b) , V2 c d ] , _flareColor = col , _flareTran3 = tranv , _flareTime = 2 } where thestate = replicateM 4 $ state $ randomR (2,20) (a : b : c : d : _, g) = runState thestate $ _randGen w -- randomRs (2, 20) (_randGen w) flareCircleAt :: Color -> Float -> Point3 -> World -> World flareCircleAt col alphax tranv = cWorld . lWorld . flares .:~ CircFlare { _flareTime = 2 , _flareColor = col , _flareAlpha = alphax , _flareTran3 = tranv } explosionFlashAt :: Point2 -> World -> World explosionFlashAt p = cWorld . lWorld . tempLightSources .:~ tlsTimeRadFunPos 20 150 (TLSFade 1 10) (addZ 20 p)