Cleanup tesla arcs
This commit is contained in:
+37
-15
@@ -2,19 +2,22 @@ module Dodge.Particle.Spark
|
||||
( colSpark
|
||||
, colSparkRandDir
|
||||
, createBarrelSpark
|
||||
, randColDirTimeSpark
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Particle.Bullet.Draw
|
||||
import Dodge.Particle.Bullet.Update
|
||||
import Dodge.WorldEvent.HitEffect
|
||||
import Dodge.Particle.Bullet.DestroyDamage
|
||||
--import Dodge.WorldEvent.HitEffect
|
||||
import Color
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
import Control.Monad.State
|
||||
import System.Random
|
||||
--import Control.Lens
|
||||
|
||||
-- TODO remove/simplify this function
|
||||
createBarrelSpark :: Point2 -> Float -> Maybe Int -> Int -> Int -> World -> World
|
||||
createBarrelSpark pos dir maycid time colid = instantParticles .:~ BulletPt
|
||||
{ _ptDraw = drawBul
|
||||
@@ -26,16 +29,40 @@ createBarrelSpark pos dir maycid time colid = instantParticles .:~ BulletPt
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = destroyOnImpact sparkEff noEff
|
||||
, _ptHitEff = bulletDestroyDamage SparkDam 1
|
||||
}
|
||||
where
|
||||
sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage
|
||||
.:~ Damage SparkDam 1 sp p ep NoDamageEffect
|
||||
where
|
||||
sp = head (_ptTrail bt)
|
||||
ep = sp +.+ _ptVel bt
|
||||
colSpark :: Int -> Color -> Point2 -> Float -> World -> World
|
||||
colSpark = colSparkRandDir 0.7
|
||||
|
||||
randColDirTimeSpark
|
||||
:: State StdGen Color
|
||||
-> State StdGen Float
|
||||
-> State StdGen Int
|
||||
-> Point2
|
||||
-> World
|
||||
-> World
|
||||
randColDirTimeSpark randcol randdir randtime pos w = w
|
||||
& instantParticles .:~ spark
|
||||
& randGen .~ g
|
||||
where
|
||||
((col,dir,time),g) = (`runState` _randGen w) $ do
|
||||
c <- randcol
|
||||
d <- randdir
|
||||
t <- randtime
|
||||
return (c,d,t)
|
||||
spark = BulletPt
|
||||
{ _ptDraw = drawBul
|
||||
, _ptUpdate = mvBullet
|
||||
, _btDrag = 0.9
|
||||
, _ptVel = rotateV dir (V2 5 0)
|
||||
, _ptColor = col
|
||||
, _ptTrail = [pos]
|
||||
, _ptCrIgnore = Nothing
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = bulletDestroyDamage SparkDam 1
|
||||
}
|
||||
|
||||
colSparkRandDir :: Float -> Int -> Color -> Point2 -> Float -> World -> World
|
||||
colSparkRandDir randDir time col pos baseDir w = w
|
||||
& instantParticles .:~ spark
|
||||
@@ -53,10 +80,5 @@ colSparkRandDir randDir time col pos baseDir w = w
|
||||
, _ptCrIgnore = Nothing
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = destroyOnImpact sparkEff noEff
|
||||
, _ptHitEff = bulletDestroyDamage SparkDam 1
|
||||
}
|
||||
sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage
|
||||
.:~ Damage SparkDam 1 sp p ep NoDamageEffect
|
||||
where
|
||||
sp = head (_ptTrail bt)
|
||||
ep = sp +.+ _ptVel bt
|
||||
|
||||
Reference in New Issue
Block a user