Refactor basic explosion

This commit is contained in:
2021-03-23 14:50:23 +01:00
parent 885fa4a67e
commit b13467053a
6 changed files with 32 additions and 61 deletions
+11 -5
View File
@@ -2,6 +2,7 @@ module Dodge.WorldEvent.Flash
where
import Dodge.Data
import Dodge.Base
import Dodge.LightSources
import Dodge.WorldEvent.ThingsHit
import Dodge.WorldEvent.HelperParticle
@@ -95,7 +96,12 @@ lowLightWidthAt :: Float -> Float -> Color -> Float -> Int -> Float -> Point2 ->
lowLightWidthAt len wdth col alphay rays rad p w = foldr (lowLightWidthHit len wdth col alphay p) w ps
where ps = map ((+.+) p) $ nRaysRad rays rad
explosionFlashAt = lowLightWidthAt 10 5 white 0.3 75 150
explosionFlashAt :: Point2 -> World -> World
explosionFlashAt p = over tempLightSources ((:) $ tLightFade 20 150 intensityFunc p)
. lowLightWidthAt 10 5 white 0.3 75 150 p
where intensityFunc x
| x < 10 = 1 / (10 - fromIntegral x)
| otherwise = 1
flameGlareAt = lowLightWidthAt 10 5 orange 0.05 8 50
@@ -105,11 +111,11 @@ lowLightDirected col alpha a b angles w
muzFlareAt :: Point2 -> World -> World
muzFlareAt p = over particles' ((:) (muzzleFlareAt p))
. lowLightAt p
muzFlareAt p = over particles' ((:) (muzzleFlarePt p))
. lowLightWidthAt 10 5 white 0.5 20 30 p
muzzleFlareAt :: Point2 -> Particle'
muzzleFlareAt (x,y) =
muzzleFlarePt :: Point2 -> Particle'
muzzleFlarePt (x,y) =
Particle'
{ _ptPict' = setDepth 0
. setLayer 1