Move flame into its own datatype
This commit is contained in:
+10
-19
@@ -20,23 +20,24 @@ 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 (hp,hthing) -> (sparkDam sk sp ep (hp,hthing) w
|
||||
, Just $ sk & skPos .~ hp & skOldPos .~ sp & skVel .~ 0)
|
||||
where
|
||||
sp = _skPos sk
|
||||
ep = sp +.+ _skVel sk
|
||||
|
||||
sparkDam
|
||||
:: Point2
|
||||
:: Spark
|
||||
-> Point2
|
||||
-> Point2
|
||||
-> (Point2, Either Creature Wall)
|
||||
-> World
|
||||
-> World
|
||||
sparkDam sp ep mayEiCrWl = case mayEiCrWl of
|
||||
sparkDam sk sp ep mayEiCrWl = case mayEiCrWl of
|
||||
(hitp,Left cr) -> creatures . ix (_crID cr) . crState . csDamage .:~ thedam hitp
|
||||
(hitp,Right wl) -> wallDamages . ix (_wlID wl) .:~ thedam hitp
|
||||
where
|
||||
thedam hitp = Damage SPARKING 1 sp hitp ep NoDamageEffect
|
||||
thedam hitp = Damage (_skDamageType sk) 1 sp hitp ep NoDamageEffect
|
||||
|
||||
createBarrelSpark :: Point2 -> Float -> Int -> World -> World
|
||||
createBarrelSpark pos dir colid = colSparkRandDir 0.1 (numColor colid) pos dir
|
||||
@@ -64,16 +65,18 @@ randColDirSpark randcol randdir pos w = w
|
||||
, _skPos = pos
|
||||
, _skOldPos = pos
|
||||
, _skWidth = 1
|
||||
, _skDamageType = SPARKING
|
||||
}
|
||||
|
||||
randSpark
|
||||
:: State StdGen Float
|
||||
:: DamageType
|
||||
-> State StdGen Float
|
||||
-> State StdGen Color
|
||||
-> State StdGen Float
|
||||
-> Point2
|
||||
-> World
|
||||
-> World
|
||||
randSpark randspeed randcol randdir pos w = w
|
||||
randSpark dt randspeed randcol randdir pos w = w
|
||||
& randGen .~ g
|
||||
& sparks .:~ Spark
|
||||
{ _skVel = rotateV dir (V2 speed 0)
|
||||
@@ -81,6 +84,7 @@ randSpark randspeed randcol randdir pos w = w
|
||||
, _skPos = pos
|
||||
, _skOldPos = pos
|
||||
, _skWidth = 1
|
||||
, _skDamageType = dt
|
||||
}
|
||||
where
|
||||
((col,dir,speed),g) = (`runState` _randGen w) $ do
|
||||
@@ -94,16 +98,3 @@ 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
|
||||
-- }
|
||||
|
||||
Reference in New Issue
Block a user