Add dust on bullet wall hit

This commit is contained in:
2021-09-13 12:23:51 +01:00
parent b27c174d93
commit 29f048cfdd
15 changed files with 93 additions and 68 deletions
+30 -35
View File
@@ -1,12 +1,15 @@
module Dodge.LightSources where
module Dodge.LightSources
( tLightTimedIntensity
, tLight
, lightAt
, colorLightAt
)
where
import Dodge.Data
--import Dodge.Base
--import Dodge.Picture.Layer
--import Dodge.LevelGen.Data
--import Geometry
--import Picture
import Geometry.Data
import Control.Lens
colorLightAt :: Point3 -> Point3 -> Int -> LightSource
colorLightAt col pos i =
LS {_lsID = i
@@ -19,46 +22,38 @@ colorLightAt col pos i =
lightAt :: Point3 -> Int -> LightSource
lightAt = colorLightAt 0.75
tLightFade :: Int -> Float -> (Int -> Float) -> Point2 -> TempLightSource
tLightFade 0 rmax intensityF (V2 x y) = TLS
tLightTimedIntensity :: Int -> Float -> (Int -> Float) -> Point2 -> TempLightSource
tLightTimedIntensity t rmax intensityF (V2 x y) = TLS
{ _tlsPos = V3 x y 0
, _tlsRad = rmax
, _tlsIntensity = f $ intensityF 0
, _tlsUpdate = \w _ -> (w, Nothing)
, _tlsTime = 0
}
where
f x' = V3 x' x' x'
tLightFade i rmax intensityF p@(V2 x y) = TLS
{ _tlsPos = V3 x y 0
, _tlsRad = rmax
, _tlsIntensity = f $ intensityF i
, _tlsUpdate = \w _ -> (w, Just $ tLightFade (i-1) rmax intensityF p)
, _tlsTime = 0
, _tlsIntensity = f $ intensityF t
, _tlsUpdate = upF
, _tlsTime = t
}
where
upF _ tls
| _tlsTime tls <= 0 = Nothing
| otherwise = Just $ tls
& tlsTime -~ 1
& tlsIntensity .~ f (intensityF (_tlsTime tls) )
f x' = V3 x' x' x'
tLightRad
tLight
:: Int
-> Float -- ^ maximal radius
-> Float -- ^ minimal radius (unused)
-> Point3
-> Point2
-> TempLightSource
tLightRad 0 rmax _ (V2 x y) = TLS
tLight t rmax col (V2 x y) = TLS
{ _tlsPos = V3 x y 1
, _tlsRad = rmax
, _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Nothing)
, _tlsTime = 0
}
tLightRad i rmax rmin p@(V2 x y) = TLS
{ _tlsPos = V3 x y 0
, _tlsRad = rmax
, _tlsIntensity = V3 0.5 0.5 0
, _tlsUpdate = \w _ -> (w, Just $ tLightRad (i-1) rmax rmin p)
, _tlsTime = 0
, _tlsIntensity = col
, _tlsUpdate = upF
, _tlsTime = t
}
where
upF _ tls
| _tlsTime tls <= 0 = Nothing
| otherwise = Just $ tls
& tlsTime -~ 1
tLightAt :: Int -> Point2 -> TempLightSource
tLightAt i = tLightRad i 100 0