Improve static bullets

This commit is contained in:
2022-07-19 13:15:13 +01:00
parent 54ba0fbedc
commit 0a7922ec5e
19 changed files with 287 additions and 134 deletions
+25
View File
@@ -0,0 +1,25 @@
module Dodge.PosEvent where
import Dodge.Data
import Dodge.Spark
import Geometry.Data
import Color
import LensHelp
import Control.Monad.State
import RandomHelp
updatePosEvent :: World -> PosEvent -> (World, Maybe PosEvent)
updatePosEvent w pv
| _pvTimer pv < 1 = (w,Nothing)
| otherwise = (posEventEffect pv w,Just $ pv & pvTimer -~ 1)
posEventEffect :: PosEvent -> World -> World
posEventEffect pv = case _pvType pv of
SparkSpawner -> spawnElectricalSparks (_pvPos pv)
spawnElectricalSparks :: Point2 -> World -> World
spawnElectricalSparks p = randSpark ELECTRICAL rspeed rcol rdir p
where
rspeed = state (randomR (3,6))
rcol = brightX 100 1.5 <$> takeOne [white,azure,blue,cyan]
rdir = state $ randomR (0,2*pi)