Basic closeness check for floor items

This commit is contained in:
2021-09-22 12:05:28 +01:00
parent 27a780ff47
commit 0295b3dd70
2 changed files with 6 additions and 12 deletions
+3 -10
View File
@@ -11,19 +11,12 @@ import Dodge.Render.ShapePicture
import qualified Data.IntMap as IM import qualified Data.IntMap as IM
worldShape :: World -> Shape worldShape :: World -> Shape
worldShape w = _foregroundShape w worldShape w = _foregroundShape w
<> mconcat (map (crShape w) (IM.elems $ IM.filter crIsClose (_creatures w))) <> mconcat (map (crShape w) (IM.elems $ IM.filter (pointIsClose . _crPos) (_creatures w)))
<> mconcat (map (_spShape . floorItemSPic) $ IM.elems $ _floorItems w) <> mconcat (map (_spShape . floorItemSPic) $ IM.elems $ IM.filter (pointIsClose . _flItPos) $ _floorItems w)
where where
crIsClose cr = dist (_crPos cr) camCen < winSize pointIsClose p = dist camCen p < winSize
winSize = 30 + max (getWindowX w) (getWindowY w) winSize = 30 + max (getWindowX w) (getWindowY w)
camCen = _cameraCenter w camCen = _cameraCenter w
pointIsClose :: World -> Point2 -> Bool
pointIsClose w p = dist p camCen < winSize
where
winSize = 30 + max (getWindowX w) (getWindowY w)
camCen = _cameraCenter w
crShape :: World -> Creature -> Shape crShape :: World -> Creature -> Shape
crShape w c = _spShape $ _crPict c c w crShape w c = _spShape $ _crPict c c w
+3 -2
View File
@@ -5,6 +5,7 @@ import Geometry
import ShapePicture import ShapePicture
floorItemSPic :: FloorItem -> SPic floorItemSPic :: FloorItem -> SPic
floorItemSPic flit = uncurryV translateSPf (_flItPos flit) floorItemSPic flit
$ rotateSP (_flItRot flit) (_itFloorPict (_flIt flit)) = uncurryV translateSPf (_flItPos flit)
$ rotateSP (_flItRot flit) (_itFloorPict (_flIt flit))