This commit is contained in:
2021-12-15 22:21:58 +00:00
parent 9dadea2c36
commit 9ead5b3979
11 changed files with 130 additions and 174 deletions
+30 -36
View File
@@ -1,8 +1,7 @@
module Dodge.WorldEvent.Shockwave
( makeShockwaveAt
, inverseShockwaveAt
)
where
) where
import Dodge.Data
import Dodge.Wall.Damage
import Dodge.Base
@@ -10,10 +9,9 @@ import Dodge.Zone
import Dodge.Picture.Layer
import Geometry
import Picture
import LensHelp
import qualified Data.IntMap.Strict as IM
import Control.Lens
-- currently very effective against walls
makeShockwaveAt
:: [Int] -- ^ IDs of invulnerable creatures.
@@ -24,25 +22,23 @@ makeShockwaveAt
-> Color -- ^ Color of shockwave.
-> World -- ^ Start world.
-> World
makeShockwaveAt is p rad dam push col = over particles (theShockwave :)
where
theShockwave = Shockwave'
{ _ptDraw = drawShockwave
, _ptUpdate = mvShockwave is
, _btColor' = col
, _btPos' = p
, _btRad' = rad
, _btDam' = dam
, _btPush' = push
, _btMaxTime' = 10
, _btTimer' = 10
}
makeShockwaveAt is p rad dam push col = instantParticles .:~ Shockwave
{ _ptDraw = drawShockwave
, _ptUpdate = mvShockwave is
, _ptColor = col
, _btPos' = p
, _btRad' = rad
, _btDam' = dam
, _btPush' = push
, _btMaxTime' = 10
, _btTimer' = 10
}
{- Shockwave picture. -}
drawShockwave :: Particle -> Picture
drawShockwave pt = setDepth 20
. setLayer 1
. setLayer 1
. uncurryV translate (_btPos' pt)
. color (_btColor' pt)
. color (_ptColor pt)
$ thickCircle rad thickness
where
r = _btRad' pt
@@ -69,8 +65,8 @@ mvShockwave is w pt
hitBlocks = wallsOnCirc p rad $ wallsNearPoint p w
damCr cr
| _crID cr `elem` is || dist (_crPos cr) p >= rad + _crRad cr = cr
| otherwise = cr & crState . crDamage %~
(PushDam dam (25 * push *.* squashNormalizeV (_crPos cr -.- p)) : )
| otherwise = cr & crState . crDamage .:~
PushDam dam (25 * push *.* squashNormalizeV (_crPos cr -.- p))
{- Create a shockwave going from an outside circle into a center point. -}
inverseShockwaveAt
:: Point2 -- Center position
@@ -79,19 +75,17 @@ inverseShockwaveAt
-> Float -- Push amount
-> World
-> World
inverseShockwaveAt p rad dam push = over particles (theShockwave :)
where
theShockwave = Shockwave'
{ _ptDraw = drawInverseShockwave
, _ptUpdate = moveInverseShockwave
, _btColor' = cyan
, _btPos' = p
, _btRad' = rad
, _btDam' = dam
, _btPush' = push
, _btMaxTime' = 10
, _btTimer' = 10
}
inverseShockwaveAt p rad dam push = particles .:~ Shockwave
{ _ptDraw = drawInverseShockwave
, _ptUpdate = moveInverseShockwave
, _ptColor = cyan
, _btPos' = p
, _btRad' = rad
, _btDam' = dam
, _btPush' = push
, _btMaxTime' = 10
, _btTimer' = 10
}
moveInverseShockwave
:: World
-> Particle
@@ -108,8 +102,8 @@ moveInverseShockwave w pt
hitBlocks = wallsOnCirc p rad $ wallsNearPoint p w
damCr cr
| dist (_crPos cr) p >= rad + _crRad cr = cr
| otherwise = cr & crState . crDamage %~
(PushDam 1 (25 *.* squashNormalizeV (p -.- _crPos cr)) :)
| otherwise = cr & crState . crDamage .:~
PushDam 1 (25 *.* squashNormalizeV (p -.- _crPos cr))
drawInverseShockwave :: Particle -> Picture
drawInverseShockwave pt