Work on energy balls
This commit is contained in:
@@ -3,6 +3,7 @@ module Dodge.Spark (
|
||||
sparkRandDir,
|
||||
randDirSpark,
|
||||
randSpark,
|
||||
randSparkExtraVel,
|
||||
makeSpark,
|
||||
) where
|
||||
|
||||
@@ -14,6 +15,7 @@ import Geometry
|
||||
import LensHelp
|
||||
import System.Random
|
||||
|
||||
-- should probably reduce spark speed more if it is very fast
|
||||
updateSpark :: World -> Spark -> (World, Maybe Spark)
|
||||
updateSpark w sk
|
||||
| magV (_skVel sk) < 1 = (w, Nothing)
|
||||
@@ -87,5 +89,29 @@ randSpark dt randspeed randdir pos w =
|
||||
x <- randspeed
|
||||
return (d, x)
|
||||
|
||||
randSparkExtraVel ::
|
||||
Point2 ->
|
||||
SparkType ->
|
||||
State StdGen Float ->
|
||||
State StdGen Float ->
|
||||
Point2 ->
|
||||
World ->
|
||||
World
|
||||
randSparkExtraVel v dt randspeed randdir pos w =
|
||||
w
|
||||
& randGen .~ g
|
||||
& cWorld . lWorld . sparks
|
||||
.:~ Spark
|
||||
{ _skVel = v + rotateV dir (V2 speed 0)
|
||||
, _skPos = pos
|
||||
, _skOldPos = pos
|
||||
, _skType = dt
|
||||
}
|
||||
where
|
||||
((dir, speed), g) = (`runState` _randGen w) $ do
|
||||
d <- randdir
|
||||
x <- randspeed
|
||||
return (d, x)
|
||||
|
||||
sparkRandDir :: Float -> Point2 -> Float -> World -> World
|
||||
sparkRandDir a pos dir = randDirSpark (state $ randomR (dir - a, dir + a)) pos
|
||||
|
||||
Reference in New Issue
Block a user