diff --git a/src/Dodge/Bullet/Draw.hs b/src/Dodge/Bullet/Draw.hs index a33ec38cf..909c183a1 100644 --- a/src/Dodge/Bullet/Draw.hs +++ b/src/Dodge/Bullet/Draw.hs @@ -1,11 +1,9 @@ module Dodge.Bullet.Draw ( drawBul ) where -import Dodge.Data +import Dodge.Data.Bullet import Picture - import Linear - drawBul :: Bullet -> Picture drawBul pt = setLayer BloomNoZWrite . setDepth 20 diff --git a/src/Dodge/Particle/TeslaArc.hs b/src/Dodge/Particle/TeslaArc.hs index 4a661b74b..64d4ee362 100644 --- a/src/Dodge/Particle/TeslaArc.hs +++ b/src/Dodge/Particle/TeslaArc.hs @@ -28,7 +28,8 @@ moveTeslaArc thearc w pt where rcol = brightX 100 1.5 <$> takeOne [white,azure,blue,cyan] rdir = state (randomR (-0.7,0.7)) <&> (+ ld) - makeaspark = randColDirTimeSpark rcol rdir lp + rspeed = state (randomR (3,6)) + makeaspark = randSpark rspeed rcol rdir lp makesparks = makeaspark . makeaspark . makeaspark (lp,ld) = case last thearc of ArcStep lp' ld' Nothing -> (lp',ld') diff --git a/src/Dodge/Spark.hs b/src/Dodge/Spark.hs index add131bcf..c64574910 100644 --- a/src/Dodge/Spark.hs +++ b/src/Dodge/Spark.hs @@ -3,7 +3,8 @@ module Dodge.Spark , colSpark , colSparkRandDir , createBarrelSpark - , randColDirTimeSpark + , randColDirSpark + , randSpark ) where import Dodge.Data import Dodge.WorldEvent.ThingsHit @@ -19,7 +20,8 @@ moveSpark w sk | magV (_skVel sk) < 1 = (w,Nothing) | otherwise = case thingHit sp ep w of Nothing -> (w, Just $ sk & skPos .~ ep & skVel .*.*~ 0.9 & skOldPos .~ sp) - Just (hp,hthing) -> (sparkDam sp ep (hp,hthing) w, Just $ sk & skPos .~ hp & skOldPos .~ sp & skVel .~ 0) + Just (hp,hthing) -> (sparkDam sp ep (hp,hthing) w + , Just $ sk & skPos .~ hp & skOldPos .~ sp & skVel .~ 0) where sp = _skPos sk ep = sp +.+ _skVel sk @@ -36,26 +38,19 @@ sparkDam sp ep mayEiCrWl = case mayEiCrWl of where thedam hitp = Damage SPARKING 1 sp hitp ep NoDamageEffect ---import Control.Lens --- TODO remove/simplify this function createBarrelSpark :: Point2 -> Float -> Int -> World -> World -createBarrelSpark pos dir colid = sparks .:~ Spark - { _skVel = rotateV dir (V2 5 0) - , _skColor = numColor colid - , _skPos = pos - , _skOldPos = pos - , _skWidth = 1 - } +createBarrelSpark pos dir colid = colSparkRandDir 0.1 (numColor colid) pos dir + colSpark :: Color -> Point2 -> Float -> World -> World colSpark = colSparkRandDir 0.7 -randColDirTimeSpark +randColDirSpark :: State StdGen Color -> State StdGen Float -> Point2 -> World -> World -randColDirTimeSpark randcol randdir pos w = w +randColDirSpark randcol randdir pos w = w & sparks .:~ spark & randGen .~ g where @@ -71,17 +66,44 @@ randColDirTimeSpark randcol randdir pos w = w , _skWidth = 1 } -colSparkRandDir :: Float -> Color -> Point2 -> Float -> World -> World -colSparkRandDir randDir col pos baseDir w = w - & sparks .:~ spark +randSpark + :: State StdGen Float + -> State StdGen Color + -> State StdGen Float + -> Point2 + -> World + -> World +randSpark randspeed randcol randdir pos w = w & randGen .~ g - where - (a,g) = randomR (-randDir,randDir) $ _randGen w - dir = a + baseDir - spark = Spark - { _skVel = rotateV dir (V2 5 0) - , _skColor = col - , _skPos = pos - , _skOldPos = pos + & sparks .:~ Spark + { _skVel = rotateV dir (V2 speed 0) + , _skColor = col + , _skPos = pos + , _skOldPos = pos , _skWidth = 1 } + where + ((col,dir,speed),g) = (`runState` _randGen w) $ do + c <- randcol + d <- randdir + x <- randspeed + return (c,d,x) + +colSparkRandDir :: Float -> Color -> Point2 -> Float -> World -> World +colSparkRandDir a col pos dir = randColDirSpark + (return col) + (state $ randomR (dir - a, dir + a)) + pos +-- w +-- & sparks .:~ spark +-- & randGen .~ g +-- where +-- (a,g) = randomR (-randDir,randDir) $ _randGen w +-- dir = a + baseDir +-- spark = Spark +-- { _skVel = rotateV dir (V2 5 0) +-- , _skColor = col +-- , _skPos = pos +-- , _skOldPos = pos +-- , _skWidth = 1 +-- } diff --git a/src/Dodge/Spark/Draw.hs b/src/Dodge/Spark/Draw.hs index f34b43aaf..929aa255d 100644 --- a/src/Dodge/Spark/Draw.hs +++ b/src/Dodge/Spark/Draw.hs @@ -1,5 +1,5 @@ module Dodge.Spark.Draw where -import Dodge.Data +import Dodge.Data.Spark import Picture drawSpark :: Spark -> Picture