Fix laser targeting draw when creature offscreen

This commit is contained in:
2022-03-06 22:58:05 +00:00
parent f82bd3f788
commit 1364e7c8c8
14 changed files with 108 additions and 138 deletions
+1 -2
View File
@@ -13,7 +13,6 @@ lightsForGloom w = mapMaybe getLS (IM.elems $ _lightSources w) ++ mapMaybe getTL
getLS = getlsparam . _lsParam
getTLS = getlsparam . _tlsParam
getlsparam ls
| dist campos (fst2 $ _lsPos ls) > 1000 = Nothing
| dist (_cameraCenter w) (fst2 $ _lsPos ls) > _viewDistance w + _lsRad ls = Nothing
| otherwise = Just ( _lsPos ls, _lsRad ls^(2::Int) , _lsCol ls)
campos = _cameraCenter w
fst2 (V3 a b _) = V2 a b
+4 -4
View File
@@ -25,6 +25,7 @@ import qualified Data.Map.Strict as M
--import Control.Lens
--import Data.Maybe
-- TODO only filter out shapes outside the range of the furthest shown light source
worldSPic :: Configuration -> World -> SPic
worldSPic cfig w =
(extraShapes w, extraPics cfig w)
@@ -35,13 +36,13 @@ worldSPic cfig w =
<> foldMap mcSPic (filtOn _mcPos _machines)
where
filtOn f g = IM.filter (pointIsClose . f) (g w)
pointIsClose p = dist camCen p < winSize
winSize = 30 + max (_windowX cfig) (_windowY cfig)
pointIsClose p = dist camCen p < 30 + _viewDistance w
camCen = _cameraCenter w
extraShapes :: World -> Shape
extraShapes = _foregroundShape
-- TODO filter out pictures not in the frame
extraPics :: Configuration -> World -> Picture
extraPics cfig w = pictures (_decorations w)
<> concatMapPic (dbArg _ptDraw) (_particles w)
@@ -53,7 +54,6 @@ extraPics cfig w = pictures (_decorations w)
<> viewBoundaries cfig w
<> drawPathing cfig w
-- TODO remove duplicate!
testPic :: World -> Picture
testPic _ = []
clDraw :: Cloud -> Picture
@@ -73,7 +73,7 @@ mcSPic bt = uncurryV translateSPf (_mcPos bt)
$ rotateSP (_mcDir bt) (_mcDraw bt bt)
soundPics :: Configuration -> World -> Picture
soundPics cfig w
soundPics cfig w
| _show_sound cfig = pictures $ M.map (soundPic cfig w) $ _playingSounds w
| otherwise = []