Add muzzle flare
This commit is contained in:
@@ -14,6 +14,8 @@ module Dodge.WorldEvent.Flash
|
||||
, laserGunFlashAt
|
||||
, teslaGunFlashAt
|
||||
, lowLightDirected
|
||||
, flareCircleAt
|
||||
, muzFlareAt
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
@@ -27,13 +29,14 @@ import Geometry
|
||||
|
||||
import Data.Maybe (maybeToList)
|
||||
import Control.Lens
|
||||
import System.Random
|
||||
|
||||
{- Cyan flash. -}
|
||||
teslaGunFlashAt :: Point2 -> World -> World
|
||||
teslaGunFlashAt :: Point3 -> World -> World
|
||||
teslaGunFlashAt = flareCircleAt cyan 0.7
|
||||
|
||||
{- Yellow flash. -}
|
||||
laserGunFlashAt :: Point2 -> World -> World
|
||||
laserGunFlashAt :: Point3 -> World -> World
|
||||
laserGunFlashAt = flareCircleAt yellow 0.2
|
||||
|
||||
glareLine' :: Int -> Float -> Float -> Color -> Point2 -> Point2 -> World -> World
|
||||
@@ -63,13 +66,27 @@ lowLightPic len wdth col (a,b) w = case thingsHit a b w of
|
||||
_ -> blank
|
||||
where setCol = color col . setDepth (-0.5) . setLayer 2
|
||||
|
||||
flareCircleAt :: Color -> Float -> Point2 -> World -> World
|
||||
flareCircleAt col alphax (V2 x y) = particles %~ (theFlareCircle :)
|
||||
muzFlareAt :: Color -> Point3 -> Float -> World -> World
|
||||
muzFlareAt col tranv dir w = w & particles %~ (theFlareCircle :)
|
||||
where
|
||||
theFlareCircle = Particle
|
||||
{ _ptDraw = const $ setLayer 2 . setDepth 20 . translate x y
|
||||
$ circleSolidCol (withAlpha 0 col) (withAlpha alphax col) 30
|
||||
, _ptUpdate = ptTimer' 1
|
||||
{ _ptDraw = const $ setLayer 1 . translate3 tranv $ theShape
|
||||
, _ptUpdate = ptSimpleTime 2
|
||||
}
|
||||
theShape = rotate dir . color col $ polygon
|
||||
[ V2 0 0
|
||||
, V2 a (-b)
|
||||
, V2 c d
|
||||
]
|
||||
(a:b:c:d:_) = randomRs (2,20) (_randGen w)
|
||||
|
||||
flareCircleAt :: Color -> Float -> Point3 -> World -> World
|
||||
flareCircleAt col alphax tranv = particles %~ (theFlareCircle :)
|
||||
where
|
||||
theFlareCircle = Particle
|
||||
{ _ptDraw = const $ setLayer 2 . translate3 tranv
|
||||
$ circleSolidCol (withAlpha alphax col) (withAlpha 0 col) 30
|
||||
, _ptUpdate = ptSimpleTime 1
|
||||
}
|
||||
|
||||
explosionFlashAt :: Point2 -> World -> World
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
{- Helper functions for particles. -}
|
||||
module Dodge.WorldEvent.HelperParticle
|
||||
( ptSimpleTime
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
|
||||
{- A simple timer update for particles. -}
|
||||
ptTimer' :: Int -> World -> Particle -> (World, Maybe Particle)
|
||||
ptTimer' 0 w _ = (w, Nothing)
|
||||
ptTimer' n w pt = (w, Just $ pt {_ptUpdate = ptTimer' (n-1)})
|
||||
ptSimpleTime :: Int -> World -> Particle -> (World, Maybe Particle)
|
||||
ptSimpleTime 0 w _ = (w, Nothing)
|
||||
ptSimpleTime n w pt = (w, Just $ pt {_ptUpdate = ptSimpleTime (n-1)})
|
||||
|
||||
Reference in New Issue
Block a user