Add file
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Flare where
|
||||
import Color
|
||||
import Geometry
|
||||
import Control.Lens
|
||||
|
||||
data Flare
|
||||
= MuzFlare
|
||||
{ _flarePoly :: [Point2]
|
||||
, _flareColor :: Color
|
||||
, _flareTran3 :: Point3
|
||||
, _flareTime :: Int
|
||||
}
|
||||
| CircFlare
|
||||
{ _flareColor :: Color
|
||||
, _flareAlpha :: Float
|
||||
, _flareTran3 :: Point3
|
||||
, _flareTime :: Int
|
||||
}
|
||||
|
||||
makeLenses ''Flare
|
||||
@@ -0,0 +1,30 @@
|
||||
module Dodge.Flare where
|
||||
import Dodge.Data.Flare
|
||||
import LensHelp
|
||||
import Picture
|
||||
|
||||
updateFlare :: Flare -> Maybe Flare
|
||||
updateFlare rb
|
||||
| _flareTime rb <= 0 = Nothing
|
||||
| otherwise = Just $ rb & flareTime -~ 1
|
||||
|
||||
drawFlare :: Flare -> Picture
|
||||
drawFlare fl = case fl of
|
||||
MuzFlare {} -> drawMuzFlare fl
|
||||
CircFlare {} -> drawCircFlare fl
|
||||
|
||||
drawMuzFlare :: Flare -> Picture
|
||||
drawMuzFlare pt = setLayer BloomNoZWrite . translate3 tranv $ theShape
|
||||
where
|
||||
tranv = _flareTran3 pt
|
||||
col = _flareColor pt
|
||||
poly = _flarePoly pt
|
||||
theShape = color col $ polygon poly
|
||||
|
||||
drawCircFlare :: Flare -> Picture
|
||||
drawCircFlare pt = setLayer BloomNoZWrite . translate3 tranv
|
||||
$ circleSolidCol (withAlpha 0 0) (withAlpha alphax col) 50
|
||||
where
|
||||
col = _flareColor pt
|
||||
tranv = _flareTran3 pt
|
||||
alphax = _flareAlpha pt
|
||||
Reference in New Issue
Block a user