Reify tesla arcs

This commit is contained in:
2022-07-23 23:46:03 +01:00
parent 7563441154
commit 97174535d8
7 changed files with 40 additions and 30 deletions
+15 -15
View File
@@ -32,23 +32,23 @@ import MonadHelp
import Data.Maybe
--import qualified IntMapHelp as IM
aTeslaArcAt :: Color -> [ArcStep] -> Particle
aTeslaArcAt col thearc = PtTeslaArc
{ _ptPoints = map (^. asPos) thearc
, _ptUpdate = moveTeslaArc thearc
, _ptTimer = 2
, _ptColor = brightX 100 1.5 col
aTeslaArcAt :: Color -> [ArcStep] -> TeslaArc
aTeslaArcAt col thearc = TeslaArc
{ _taPoints = map (^. asPos) thearc
, _taArcSteps = thearc
, _taTimer = 2
, _taColor = brightX 100 1.5 col
}
moveTeslaArc :: [ArcStep]
-> World
-> Particle
-> (World,Maybe Particle)
moveTeslaArc thearc w pt
| _ptTimer pt == 2 = (makesparks $ foldr damthings w thearc, Just $ pt & ptTimer -~ 1)
| _ptTimer pt < 1 = (w, Nothing)
| otherwise = (w, Just $ pt & ptTimer -~ 1)
moveTeslaArc :: World
-> TeslaArc
-> (World,Maybe TeslaArc)
moveTeslaArc w pt
| _taTimer pt == 2 = (makesparks $ foldr damthings w thearc, Just $ pt & taTimer -~ 1)
| _taTimer pt < 1 = (w, Nothing)
| otherwise = (w, Just $ pt & taTimer -~ 1)
where
thearc = _taArcSteps pt
rcol = brightX 100 1.5 <$> takeOne [white,azure,blue,cyan]
rdir = state (randomR (-0.7,0.7)) <&> (+ ld)
rspeed = state (randomR (3,6))
@@ -71,7 +71,7 @@ moveTeslaArc thearc w pt
shootTeslaArc' :: ItemParams -> Point2 -> Float -> World -> (World,ItemParams)
shootTeslaArc' ip pos dir w =
(w & randGen .~ g
& instantParticles .:~ aTeslaArcAt col newarc
& teslaArcs .:~ aTeslaArcAt col newarc
, ip & currentArc ?~ newarc
)
where