Allow tweaking z buffer when rendering polygon, improve explosion render
This commit is contained in:
@@ -20,6 +20,7 @@ import Dodge.RandomHelp
|
||||
--import Dodge.Debug
|
||||
import Picture
|
||||
import Geometry
|
||||
--import Geometry.Data
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
import Control.Lens
|
||||
@@ -56,9 +57,9 @@ drawFlame rotd pt = thePic
|
||||
ep = _btPos' pt
|
||||
thePic = pictures
|
||||
[ glow
|
||||
, aPic prot2 0.002998 (scaleChange + 1,2) red
|
||||
, aPic prot 0.002996 (scaleChange + 0.5,1.5) orange
|
||||
, aPic prot3 0.002994 (scaleChange,1) white
|
||||
, aPic prot2 18 (scaleChange + 1,2) red
|
||||
, aPic prot 19 (scaleChange + 0.5,1.5) orange
|
||||
, aPic prot3 20 (scaleChange,1) white
|
||||
]
|
||||
aPic :: (Point2 -> Point2) -> Float -> Point2 -> Color -> Picture
|
||||
aPic offset depth (scalex,scaley) col
|
||||
@@ -121,31 +122,80 @@ moveFlame rotd w pt
|
||||
+.+ (0.2 *.* vel)
|
||||
smokeCol = fst $ randomR (0.2,0.5) (_randGen w)
|
||||
smokeGen = makeFlamerSmokeAt smokeCol ep
|
||||
|
||||
makeFlameletTimed
|
||||
:: Point2 -- ^ Position
|
||||
-> Float -- ^ z position
|
||||
-> Point2 -- ^ Velocity
|
||||
-> Maybe Int -- ^ Creature id
|
||||
-> Float -- ^ Size
|
||||
-> Int -- ^ Timer
|
||||
-> World
|
||||
-> World
|
||||
makeFlameletTimed pos vel maycid size time w = w
|
||||
makeFlameletTimed (x,y) z vel maycid size time w = w
|
||||
& randGen .~ g
|
||||
& particles %~ (theFlamelet :)
|
||||
where
|
||||
theFlamelet = Pt'
|
||||
{ _ptDraw = drawFlamelet rot
|
||||
theFlamelet = PtZ
|
||||
{ _ptDraw = drawFlameletZ rot
|
||||
, _ptUpdate' = moveFlamelet
|
||||
, _btVel' = vel
|
||||
, _btColor' = red
|
||||
, _btPos' = pos
|
||||
, _btPos' = (x,y)
|
||||
, _btPassThrough' = maycid
|
||||
, _btWidth' = size
|
||||
, _btTimer' = time
|
||||
, _btHitEffect' = destroyOnImpact (doFlameDam 1) noEff noEff
|
||||
, _ptZ = z
|
||||
}
|
||||
(rot ,g) = randomR (0,3) $ _randGen w
|
||||
|
||||
drawFlameletZ
|
||||
:: Float -- ^ Rotation
|
||||
-> Particle
|
||||
-> Picture
|
||||
drawFlameletZ rot pt = pictures
|
||||
[ setLayer 5 pic
|
||||
, setLayer 4 pi2
|
||||
, setLayer 3 piu
|
||||
, setLayer 1 glow
|
||||
]
|
||||
where
|
||||
z = _ptZ pt
|
||||
sp = _btPos' pt
|
||||
vel = _btVel' pt
|
||||
ep = sp +.+ vel
|
||||
size = _btWidth' pt
|
||||
siz2 = size + 0.2
|
||||
time = _btTimer' pt
|
||||
glow = setDepth 19 $ uncurry translate ep
|
||||
$ circleSolidCol (withAlpha 0 red) (withAlpha 0.05 red) 30
|
||||
piu = setDepth (z + 20)
|
||||
. uncurry translate ep
|
||||
. color (dark red)
|
||||
. rotate (negate (rot - 0.1 * fromIntegral time))
|
||||
. scale s1 s1
|
||||
$ polygon (rectNSWE siz2 (-siz2) (-siz2) siz2)
|
||||
pi2 = setDepth (z + 20)
|
||||
. uncurry translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
orange (dark red)
|
||||
)
|
||||
. rotate (negate (rot + 0.2 * fromIntegral time))
|
||||
. scale s2 s2
|
||||
$ polygon (rectNSWE siz2 (-siz2) (-siz2) siz2)
|
||||
pic = setDepth (z + 20)
|
||||
. uncurry translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
white (dark red)
|
||||
)
|
||||
. rotate (negate ( 0.1 * fromIntegral time + rot))
|
||||
. scale sc sc
|
||||
$ polygon [(-size,-size),(size,-size),(size,size),(-size,size)]
|
||||
sc = (*) 2 $ log $ 1 + fromIntegral time / 20
|
||||
s1 = (*) 2 $ log $ 2 + fromIntegral time / 40
|
||||
s2 = 0.5 * (sc + s1)
|
||||
|
||||
drawFlamelet
|
||||
:: Float -- ^ Rotation
|
||||
-> Particle
|
||||
@@ -158,16 +208,16 @@ drawFlamelet rot pt = setLayer 1 $ pictures [pic , piu , pi2 , glow]
|
||||
size = _btWidth' pt
|
||||
siz2 = size + 0.2
|
||||
time = _btTimer' pt
|
||||
glow = setDepth 0.336 $ uncurry translate ep
|
||||
glow = setDepth 19 $ uncurry translate ep
|
||||
$ circleSolidCol (withAlpha 0 red) (withAlpha 0.05 red) 30
|
||||
piu = setDepth 0.334
|
||||
piu = setDepth 20
|
||||
. uncurry translate ep
|
||||
. color (dark red)
|
||||
. rotate (negate (rot - 0.1 * fromIntegral time))
|
||||
. scale s1 s1
|
||||
. polygon
|
||||
$ rectNSWE siz2 (-siz2) (-siz2) siz2
|
||||
pi2 = setDepth 0.332
|
||||
pi2 = setDepth 20.2
|
||||
. uncurry translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
orange (dark red)
|
||||
@@ -176,7 +226,7 @@ drawFlamelet rot pt = setLayer 1 $ pictures [pic , piu , pi2 , glow]
|
||||
. scale s2 s2
|
||||
. polygon
|
||||
$ rectNSWE siz2 (-siz2) (-siz2) siz2
|
||||
pic = setDepth 0.33
|
||||
pic = setDepth 20.4
|
||||
. uncurry translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
white (dark red)
|
||||
@@ -251,10 +301,10 @@ drawTeslaArc pt = pic
|
||||
where
|
||||
ps' = _ptPoints pt
|
||||
pic = setLayer 1 $ pictures
|
||||
[ onLayer PtLayer $ color (_ptColor pt) $ line ps'
|
||||
, onLayer UPtLayer $ color (withAlpha 0.02 cyan) $ lineOfThickness 20 ps'
|
||||
, onLayer UPtLayer $ color (withAlpha 0.02 cyan) $ lineOfThickness 25 ps'
|
||||
, onLayer UPtLayer $ color (withAlpha 0.02 cyan) $ lineOfThickness 30 ps'
|
||||
[ setDepth 20.5 $ color (_ptColor pt) $ line ps'
|
||||
, setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 20 ps'
|
||||
, setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 25 ps'
|
||||
, setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 30 ps'
|
||||
]
|
||||
-- todo: fix electrical damage location
|
||||
moveTeslaArc
|
||||
|
||||
Reference in New Issue
Block a user