Cleanup
This commit is contained in:
@@ -13,21 +13,15 @@ module Dodge.WorldEvent.Flash
|
||||
, explosionFlashAt
|
||||
, laserGunFlashAt
|
||||
, teslaGunFlashAt
|
||||
, lowLightDirected
|
||||
, flareCircleAt
|
||||
, muzFlareAt
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
--import Dodge.Base
|
||||
import Dodge.Picture
|
||||
import Dodge.LightSources.Lamp
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.WorldEvent.HelperParticle
|
||||
import Picture
|
||||
import Geometry
|
||||
|
||||
import Data.Maybe (maybeToList)
|
||||
import Control.Lens
|
||||
import System.Random
|
||||
|
||||
@@ -39,37 +33,10 @@ teslaGunFlashAt = flareCircleAt cyan 0.7
|
||||
laserGunFlashAt :: Point3 -> World -> World
|
||||
laserGunFlashAt = flareCircleAt yellow 0.2
|
||||
|
||||
glareLine' :: Int -> Float -> Float -> Color -> Point2 -> Point2 -> World -> World
|
||||
glareLine' t len wdth col a b w = w & particles %~ (maybeToList linePt ++)
|
||||
where
|
||||
linePt :: Maybe Particle
|
||||
linePt = glareBetween t len wdth col 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 -> (Point2, Point2) -> World -> Picture
|
||||
lowLightPic len wdth col (a,b) w = case thingsHit a b w of
|
||||
((p, E3x2 wall):_)
|
||||
-> setCol . lineOfThickness wdth $ [alongSegBy len p wa, alongSegBy len p wb]
|
||||
where
|
||||
(wa,wb) = _wlLine wall
|
||||
((p, E3x1 cr):_)
|
||||
-> setCol . uncurryV translate cp . rotate (-0.25 * pi + argV (p -.- cp))
|
||||
$ thickArc 0 (pi/2) (_crRad cr) wdth
|
||||
where
|
||||
cp = _crPos cr
|
||||
_ -> blank
|
||||
where setCol = color col . setDepth (-0.5) . setLayer 2
|
||||
|
||||
muzFlareAt :: Color -> Point3 -> Float -> World -> World
|
||||
muzFlareAt col tranv dir w = w & particles %~ (theFlareCircle :)
|
||||
muzFlareAt col tranv dir w = w & particles %~ (theFlare :)
|
||||
where
|
||||
theFlareCircle = Particle
|
||||
theFlare = Particle
|
||||
{ _ptDraw = const $ setLayer 1 . translate3 tranv $ theShape
|
||||
, _ptUpdate = ptSimpleTime 2
|
||||
}
|
||||
@@ -84,21 +51,17 @@ flareCircleAt :: Color -> Float -> Point3 -> World -> World
|
||||
flareCircleAt col alphax tranv = particles %~ (theFlareCircle :)
|
||||
where
|
||||
theFlareCircle = Particle
|
||||
{ _ptDraw = const $ setLayer 2 . translate3 tranv
|
||||
{ _ptDraw = const . setLayer 1 . translate3 tranv
|
||||
$ circleSolidCol (withAlpha alphax col) (withAlpha 0 col) 30
|
||||
, _ptUpdate = ptSimpleTime 1
|
||||
}
|
||||
|
||||
explosionFlashAt :: Point2 -> World -> World
|
||||
explosionFlashAt p = over tempLightSources ((:) $ tLightTimedIntensity 20 150 intensityFunc p)
|
||||
explosionFlashAt p = tempLightSources %~ (tLightTimedIntensity 20 150 intensityFunc p :)
|
||||
where
|
||||
intensityFunc x
|
||||
| x < 10 = 1 / (10 - fromIntegral x)
|
||||
| otherwise = 1
|
||||
|
||||
lowLightDirected :: Color -> Point2 -> Point2 -> [Float] -> World -> World
|
||||
lowLightDirected col a b angles w
|
||||
= foldr (\angle w' -> glareLine' 2 10 5 col a (a +.+ rotateV angle b) w') w angles
|
||||
|
||||
sparkFlashAt :: Point2 -> World -> World
|
||||
sparkFlashAt _ = id
|
||||
|
||||
Reference in New Issue
Block a user