Start work on lasguns

This commit is contained in:
2022-07-06 22:24:02 +01:00
parent d63495e335
commit 0eb2fdc37e
9 changed files with 38 additions and 34 deletions
+3 -5
View File
@@ -14,19 +14,17 @@ import Data.Tuple
--import Streaming
--import qualified Streaming.Prelude as S
-- not sure why we need to keep a list of seen walls, but seems to loop
-- infinitely when removed
-- this needs to be tested with both reflections and refractions
-- the distance of the laser should be limited
reflectLaserAlong :: Float -> Point2 -> Point2 -> World
-> (Maybe (Point2,Either Creature Wall),[Point2])
reflectLaserAlong phasev sp ep w = case thingHit sp ep w of
{-# INLINE reflectLaserAlong #-}
reflectLaserAlong phasev sp ep w = case thingHitFilt (const True) _wlDraw sp ep w of
Just (p,Right wl)
| _wlReflect wl -> second (p:) $ reflectLaserAlong phasev
(p +.+ unitVectorAtAngle (reflDirWall sp p wl))
(p +.+ (dist p ep) *.* unitVectorAtAngle (reflDirWall sp p wl))
w
| wlIsSeeThrough wl && _wlSeen wl -> second (p:) $ reflectLaserAlong phasev
| wlIsSeeThrough wl -> second (p:) $ reflectLaserAlong phasev
(p +.+ normalizeV (refract sp ep wl p))
(refract sp ep wl p)
w