This commit is contained in:
2022-07-18 12:31:52 +01:00
parent 5495d33389
commit c14b3ff787
4 changed files with 50 additions and 29 deletions
+1 -3
View File
@@ -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
+2 -1
View File
@@ -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')
+46 -24
View File
@@ -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
-- }
+1 -1
View File
@@ -1,5 +1,5 @@
module Dodge.Spark.Draw where
import Dodge.Data
import Dodge.Data.Spark
import Picture
drawSpark :: Spark -> Picture