Add basic booster
This commit is contained in:
@@ -10,26 +10,26 @@ import qualified IntMapHelp as IM
|
||||
import Control.Lens
|
||||
|
||||
makeCloudAt :: Float -> Int -> (Cloud -> Picture) -> Point2 -> World -> World
|
||||
makeCloudAt rad t drawFunc p w
|
||||
= w & clouds %~ IM.insert i theCloud
|
||||
where i = IM.newKey $ _clouds w
|
||||
theCloud = Cloud { _clID = i
|
||||
, _clPos = p
|
||||
, _clVel = (0,0)
|
||||
, _clPict = drawFunc
|
||||
, _clRad = rad
|
||||
, _clTimer = t
|
||||
, _clEffect = const id
|
||||
}
|
||||
makeCloudAt rad t drawFunc p w = w & clouds %~ IM.insert i theCloud
|
||||
where
|
||||
i = IM.newKey $ _clouds w
|
||||
theCloud = Cloud
|
||||
{ _clID = i
|
||||
, _clPos = p
|
||||
, _clVel = (0,0)
|
||||
, _clPict = drawFunc
|
||||
, _clRad = rad
|
||||
, _clTimer = t
|
||||
, _clEffect = const id
|
||||
}
|
||||
|
||||
drawCloudWith :: Float -> Float -> Color -> Cloud -> Picture
|
||||
drawCloudWith radMult fadet col cl
|
||||
= setLayer 2
|
||||
. setDepth (-0.5)
|
||||
$ circleSolidCol (withAlpha 0 col) (withAlpha a col) (radMult * _clRad cl)
|
||||
-- . color (withAlpha a col)
|
||||
-- $ circleSolid (radMult * _clRad cl)
|
||||
where a = min 1 $ fromIntegral (_clTimer cl) / fadet
|
||||
. setDepth (-0.5)
|
||||
$ circleSolidCol (withAlpha 0 col) (withAlpha a col) (radMult * _clRad cl)
|
||||
where
|
||||
a = min 1 $ fromIntegral (_clTimer cl) / fadet
|
||||
|
||||
makeThickSmokeAt :: Point2 -> World -> World
|
||||
makeThickSmokeAt = makeCloudAt 3 50 (drawCloudWith 4 50 black)
|
||||
@@ -41,8 +41,8 @@ makeSmokeCloudAt :: Point2 -> World -> World
|
||||
--makeSmokeCloudAt = makeCloudAt 10 200 (drawCloudWith 2 200 (greyN 0.5))
|
||||
makeSmokeCloudAt = makeCloudAt 15 400 (drawCloudWith (4/3) 800 (greyN 0.5))
|
||||
|
||||
makeFlamerSmokeAt :: Point2 -> World -> World
|
||||
makeFlamerSmokeAt = makeCloudAt 3 200 (drawCloudWith 4 200 (greyN 0.5))
|
||||
makeFlamerSmokeAt :: Float -> Point2 -> World -> World
|
||||
makeFlamerSmokeAt x = makeCloudAt 6 200 (drawCloudWith 4 300 (greyN x))
|
||||
|
||||
spawnSmokeAtCursor :: World -> World
|
||||
spawnSmokeAtCursor w = makeSmokeCloudAt (mouseWorldPos w) w
|
||||
|
||||
@@ -36,7 +36,7 @@ aFlameParticle
|
||||
-> Maybe Int -- ^ Creature id
|
||||
-> Particle
|
||||
aFlameParticle t pos vel maycid = Pt'
|
||||
{ _ptDraw = drawFlame vel
|
||||
{ _ptDraw = drawFlame vel
|
||||
, _ptUpdate' = moveFlame vel
|
||||
, _btVel' = vel
|
||||
, _btColor' = red
|
||||
@@ -47,15 +47,6 @@ aFlameParticle t pos vel maycid = Pt'
|
||||
, _btHitEffect' = destroyOnImpact (doFlameDam 1) noEff noEff
|
||||
}
|
||||
|
||||
makeFlame
|
||||
:: Int -- ^ Timer
|
||||
-> Point2 -- ^ Position
|
||||
-> Point2 -- ^ Velocity
|
||||
-> Maybe Int -- ^ Creature id
|
||||
-> World
|
||||
-> World
|
||||
makeFlame t pos vel maycid = over particles (aFlameParticle t pos vel maycid : )
|
||||
|
||||
drawFlame
|
||||
:: Point2 -- ^ Rotate direction
|
||||
-> Particle -> Picture
|
||||
@@ -87,9 +78,7 @@ drawFlame rotd pt = thePic
|
||||
prot2 p' = p' +.+ rotateV (negate $ fromIntegral time) (0,1)
|
||||
prot3 p' = p' +.+ rotateV (2 + fromIntegral time * 0.1) (0,2)
|
||||
|
||||
{-
|
||||
TODO: add generalised area damage particles/hiteffects.
|
||||
-}
|
||||
{- TODO: add generalised area damage particles/hiteffects. -}
|
||||
moveFlame
|
||||
:: Point2 -- ^ Rotation direction
|
||||
-> World
|
||||
@@ -98,13 +87,12 @@ moveFlame
|
||||
moveFlame rotd w pt
|
||||
| time <= 0 = (smokeGen w, Nothing)
|
||||
| otherwise = case thingsHitExceptCr (_btPassThrough' pt) sp ep w of
|
||||
((_,E3x1 _):_) -> (soundAndGlare damcrs , mvPt')
|
||||
(thing@(p,E3x2 wl):_) -> (fst $ hiteff [thing] damcrs , rfl wl p)
|
||||
_ -> (soundAndGlare damcrs , mvPt)
|
||||
((_,E3x1 _):_) -> (soundAndGlare damcrs , mvPt')
|
||||
(thing@(p,E3x2 wl):_) -> (fst $ hiteff [thing] damcrs , rfl wl p)
|
||||
_ -> (soundAndGlare damcrs , mvPt)
|
||||
where
|
||||
time = _btTimer' pt
|
||||
soundAndGlare = soundFrom Flame fireSound 2 500
|
||||
. over worldEvents ((.) $ flameGlareAt ep)
|
||||
soundAndGlare = soundFrom Flame fireSound 2 500 . over worldEvents ((.) $ flameGlareAt ep)
|
||||
sp = _btPos' pt
|
||||
vel = _btVel' pt
|
||||
ep = sp +.+ vel
|
||||
@@ -130,8 +118,8 @@ moveFlame rotd w pt
|
||||
pOut p = p +.+ safeNormalizeV (sp -.- p)
|
||||
reflV wall = (0.3 *.* reflectIn (uncurry (-.-) . swap $ _wlLine wall) vel )
|
||||
+.+ (0.2 *.* vel)
|
||||
smokeGen = makeFlamerSmokeAt ep
|
||||
|
||||
smokeCol = fst $ randomR (0.2,0.5) (_randGen w)
|
||||
smokeGen = makeFlamerSmokeAt smokeCol ep
|
||||
makeFlameletTimed
|
||||
:: Point2 -- ^ Position
|
||||
-> Point2 -- ^ Velocity
|
||||
@@ -404,7 +392,7 @@ createSpark time colid pos dir maycid w
|
||||
where
|
||||
spark = Bul'
|
||||
{ _ptDraw = drawBul
|
||||
, _ptUpdate' = mvGenBullet'
|
||||
, _ptUpdate' = mvGenBullet
|
||||
, _btVel' = rotateV dir (5,0)
|
||||
, _btColor' = numColor colid
|
||||
, _btTrail' = [pos]
|
||||
@@ -425,7 +413,7 @@ createSparkCol time col pos dir maycid w
|
||||
where
|
||||
spark = Bul'
|
||||
{ _ptDraw = drawBul
|
||||
, _ptUpdate' = mvGenBullet'
|
||||
, _ptUpdate' = mvGenBullet
|
||||
, _btVel' = rotateV dir (5,0)
|
||||
, _btColor' = col
|
||||
, _btTrail' = [pos]
|
||||
|
||||
Reference in New Issue
Block a user