Commit before moving configuration outside of world

This commit is contained in:
2021-11-28 20:31:04 +00:00
parent 5cbe394e08
commit 98e44f0eee
5 changed files with 23 additions and 21 deletions
+1 -1
View File
@@ -303,7 +303,7 @@ modClock n chainEff eff it cr w
| otherwise = eff it cr w | otherwise = eff it cr w
withMuzFlareI :: ChainEffect withMuzFlareI :: ChainEffect
withMuzFlareI f it cr w = makeTLight 3 100 (V3 1 1 0.5) flashPos withMuzFlareI f it cr w = makeTlsTimeRadColPos 3 100 (V3 1 1 0.5) flashPos
. muzFlareAt (V4 5 5 0 2) flarePos dir . muzFlareAt (V4 5 5 0 2) flarePos dir
$ f it cr w $ f it cr w
where where
+13 -11
View File
@@ -21,14 +21,15 @@ import Dodge.Creature.State.Data
import Dodge.Data import Dodge.Data
import Geometry import Geometry
import Color import Color
import LensHelp
import Control.Lens --import Control.Lens
import System.Random import System.Random
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
createBarrelSpark :: Point2 -> Float -> Maybe Int -> Int -> Int -> World -> World createBarrelSpark :: Point2 -> Float -> Maybe Int -> Int -> Int -> World -> World
createBarrelSpark pos dir maycid time colid w createBarrelSpark pos dir maycid time colid w = w
= over worldEvents (( over particles (spark :) . sparkFlashAt pos') . ) w & worldEvents %~ (( over particles (spark :) . sparkFlashAt pos') . )
where where
spark = BulletPt spark = BulletPt
{ _ptDraw = drawBul { _ptDraw = drawBul
@@ -43,16 +44,17 @@ createBarrelSpark pos dir maycid time colid w
} }
x = fst $ randomR (0,20) $ _randGen w x = fst $ randomR (0,20) $ _randGen w
pos' = pos +.+ rotateV dir (V2 x 0) pos' = pos +.+ rotateV dir (V2 x 0)
sparkEff bt p cr = over (creatures . ix (_crID cr) . crState . crDamage) sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage .:~ SparkDam 1 sp p ep
((:) $ SparkDam 1 sp p ep) where
where sp = head (_btTrail' bt) sp = head (_btTrail' bt)
ep = sp +.+ _btVel' bt ep = sp +.+ _btVel' bt
damCrsOnLine :: Int -> Point2 -> Point2 -> World -> World damCrsOnLine :: Int -> Point2 -> Point2 -> World -> World
damCrsOnLine dam p1 p2 = over creatures (IM.map damIfOnLine) damCrsOnLine dam p1 p2 = creatures %~ IM.map damIfOnLine
where damIfOnLine cr | circOnSeg p1 p2 (_crPos cr) (_crRad cr) where
= over crHP (\hp -> hp - dam) cr damIfOnLine cr
| circOnSeg p1 p2 (_crPos cr) (_crRad cr) = cr & crHP -~ dam
| otherwise = cr | otherwise = cr
makeTLight :: Int -> Float -> Point3 -> Point3 -> World -> World makeTlsTimeRadColPos :: Int -> Float -> Point3 -> Point3 -> World -> World
makeTLight i rad (V3 r g b) p = tempLightSources %~ (tlsTimeRadColPos i rad (V3 r g b) p :) makeTlsTimeRadColPos i rad (V3 r g b) p = tempLightSources .:~ tlsTimeRadColPos i rad (V3 r g b) p
+5 -5
View File
@@ -22,8 +22,8 @@ import Dodge.WorldEvent.HelperParticle
--import Dodge.Default --import Dodge.Default
import Picture import Picture
import Geometry import Geometry
import LensHelp
import Control.Lens
import System.Random import System.Random
{- Cyan flash. -} {- Cyan flash. -}
@@ -35,7 +35,7 @@ laserGunFlashAt :: Point3 -> World -> World
laserGunFlashAt = flareCircleAt yellow 0.2 laserGunFlashAt = flareCircleAt yellow 0.2
muzFlareAt :: Color -> Point3 -> Float -> World -> World muzFlareAt :: Color -> Point3 -> Float -> World -> World
muzFlareAt col tranv dir w = w & particles %~ (theFlare :) muzFlareAt col tranv dir w = w & particles .:~ theFlare
where where
theFlare = Particle theFlare = Particle
{ _ptDraw = const $ setLayer 1 . translate3 tranv $ theShape { _ptDraw = const $ setLayer 1 . translate3 tranv $ theShape
@@ -49,7 +49,7 @@ muzFlareAt col tranv dir w = w & particles %~ (theFlare :)
(a:b:c:d:_) = randomRs (2,20) (_randGen w) (a:b:c:d:_) = randomRs (2,20) (_randGen w)
flareCircleAt :: Color -> Float -> Point3 -> World -> World flareCircleAt :: Color -> Float -> Point3 -> World -> World
flareCircleAt col alphax tranv = particles %~ (theFlareCircle :) flareCircleAt col alphax tranv = particles .:~ theFlareCircle
where where
theFlareCircle = Particle theFlareCircle = Particle
{ _ptDraw = const . setLayer 1 . translate3 tranv { _ptDraw = const . setLayer 1 . translate3 tranv
@@ -58,7 +58,7 @@ flareCircleAt col alphax tranv = particles %~ (theFlareCircle :)
} }
explosionFlashAt :: Point2 -> World -> World explosionFlashAt :: Point2 -> World -> World
explosionFlashAt p = tempLightSources %~ (tlsTimeRadFunPos 20 150 intensityFunc (addZ 20 p) :) explosionFlashAt p = tempLightSources .:~ tlsTimeRadFunPos 20 150 intensityFunc (addZ 20 p)
where where
intensityFunc x intensityFunc x
| x < 10 = 1 / (10 - fromIntegral x) | x < 10 = 1 / (10 - fromIntegral x)
@@ -69,7 +69,7 @@ sparkFlashAt _ = id
flameFlicker :: Particle -> World -> World flameFlicker :: Particle -> World -> World
flameFlicker pt flameFlicker pt
| _btTimer' pt `mod` 5 == 0 = tempLightSources %~ (theLight :) | _btTimer' pt `mod` 5 == 0 = tempLightSources .:~ theLight
| otherwise = id | otherwise = id
where where
V2 x y = _btPos' pt V2 x y = _btPos' pt