Move bullets into own data type

This commit is contained in:
2022-07-16 21:15:25 +01:00
parent 22adcb89e0
commit 301946ff8f
21 changed files with 216 additions and 108 deletions
+9 -9
View File
@@ -19,10 +19,10 @@ import System.Random
--import Control.Lens
-- TODO remove/simplify this function
createBarrelSpark :: Point2 -> Float -> Int -> Int -> World -> World
createBarrelSpark pos dir time colid = instantParticles .:~ BulletPt
{ _ptUpdate = mvBullet
createBarrelSpark pos dir time colid = instantParticles .:~ PtSpark
{ _ptUpdate = mvSpark
, _ptVel = rotateV dir (V2 5 0)
, _btDrag = 0.9
, _ptDrag = 0.9
, _ptColor = numColor colid
, _ptTrail = [pos]
, _ptWidth = 1
@@ -48,9 +48,9 @@ randColDirTimeSpark randcol randdir randtime pos w = w
d <- randdir
t <- randtime
return (c,d,t)
spark = BulletPt
{ _ptUpdate = mvBullet
, _btDrag = 0.9
spark = PtSpark
{ _ptUpdate = mvSpark
, _ptDrag = 0.9
, _ptVel = rotateV dir (V2 5 0)
, _ptColor = col
, _ptTrail = [pos]
@@ -66,9 +66,9 @@ colSparkRandDir randDir time col pos baseDir w = w
where
(a,g) = randomR (-randDir,randDir) $ _randGen w
dir = a + baseDir
spark = BulletPt
{ _ptUpdate = mvBullet
, _btDrag = 0.9
spark = PtSpark
{ _ptUpdate = mvSpark
, _ptDrag = 0.9
, _ptVel = rotateV dir (V2 5 0)
, _ptColor = col
, _ptTrail = [pos]