Prop reification/splitting

This commit is contained in:
2022-07-24 13:45:05 +01:00
parent 5a2f529182
commit ac069d08f6
31 changed files with 585 additions and 458 deletions
+34
View File
@@ -0,0 +1,34 @@
module Dodge.LinearShockwave.Draw
where
import Geometry.Vector
import Geometry.Data
import ListHelp
import Dodge.Data.LinearShockwave
import Picture
import Data.Maybe
drawLinearShockwave :: LinearShockwave -> Picture
drawLinearShockwave lw = setLayer BloomLayer $ setDepth 20 $ pictures $
theArc ++
[ lineCol $ zip (reverse lps) $ map (`withAlpha` white) [0,0.05..]
, lineCol $ zip (reverse rps) $ map (`withAlpha` white) [0,0.05..]
]
where
-- drawing half a circle here is not perfect, a slightly smaller arc would fit
-- better, but this depends upon the angle formed by the following lines, which
-- is not fixed (it varies with speed and angle of last turn)
theArc = maybeToList $ do
(hp,hv) <- safeHead pvs
r <- safeHead xs
return $ color (snd $ last lpairs) $ uncurryV translate hp
$ arc (argV hv - pi/2) (argV hv + pi/2) $ r * magV hv
cols = map (`withAlpha` white) [0,0.05..]
lpairs = zip (reverse lps) cols
pvs = _lwPoints lw
t = _lwTimer lw
xs = take t $ drop (20 - t) [1,1.2..]
lps = zipWith f pvs xs
rps = zipWith g pvs xs
f (p,v) x = p +.+ x *.* vNormal v
g (p,v) x = p -.- x *.* vNormal v
+16
View File
@@ -0,0 +1,16 @@
module Dodge.LinearShockwave.Update
where
import Dodge.Data
import qualified IntMapHelp as IM
import Control.Lens
updateLinearShockwave :: LinearShockwave -> World -> World
updateLinearShockwave lw w
| t < 1 = w & linearShockwaves %~ IM.delete lwid
| otherwise = w & linearShockwaves . ix lwid . lwTimer -~ 1
where
lwid = _lwID lw
t = _lwTimer lw