35 lines
935 B
Haskell
35 lines
935 B
Haskell
module Dodge.Laser.Update (updateLaser, drawLaser) where
|
|
|
|
import Dodge.Damage
|
|
import Control.Lens
|
|
import Dodge.Data.World
|
|
import Dodge.Item.Location
|
|
import Dodge.Item.Weapon.LaserPath
|
|
import Geometry
|
|
import Picture.Base
|
|
|
|
updateLaser :: World -> Laser -> (World, Picture)
|
|
updateLaser w pt =
|
|
( case _lpType pt of
|
|
DamageLaser dam ->
|
|
damThingHitWith
|
|
(\p2 -> Lasering dam p2 (xp - sp))
|
|
thHit
|
|
w
|
|
TargetingLaser itid -> w & pointerToItemID itid . itTargeting . itTgPos ?~ last ps
|
|
, drawLaser (_lpColor pt) (sp : ps)
|
|
)
|
|
where
|
|
phasev = _lpPhaseV pt
|
|
sp = _lpPos pt
|
|
dir = _lpDir pt
|
|
xp = sp +.+ 800 *.* unitVectorAtAngle dir
|
|
(thHit, ps) = reflectLaserAlong phasev sp xp w
|
|
|
|
drawLaser :: Color -> [Point2] -> Picture
|
|
drawLaser col =
|
|
setLayer BloomNoZWrite
|
|
. setDepth 19.5
|
|
. color (brightX 10 1 col)
|
|
. thickLine 3
|