From 0295b3dd70d3474a9b29266e79878cff1a2a7eb9 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 22 Sep 2021 12:05:28 +0100 Subject: [PATCH] Basic closeness check for floor items --- src/Dodge/Render/Shape.hs | 13 +++---------- src/Dodge/Render/ShapePicture.hs | 5 +++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Dodge/Render/Shape.hs b/src/Dodge/Render/Shape.hs index 8f7eaaf76..1cf00baff 100644 --- a/src/Dodge/Render/Shape.hs +++ b/src/Dodge/Render/Shape.hs @@ -11,19 +11,12 @@ import Dodge.Render.ShapePicture import qualified Data.IntMap as IM worldShape :: World -> Shape worldShape w = _foregroundShape w - <> mconcat (map (crShape w) (IM.elems $ IM.filter crIsClose (_creatures w))) - <> mconcat (map (_spShape . floorItemSPic) $ IM.elems $ _floorItems w) + <> mconcat (map (crShape w) (IM.elems $ IM.filter (pointIsClose . _crPos) (_creatures w))) + <> mconcat (map (_spShape . floorItemSPic) $ IM.elems $ IM.filter (pointIsClose . _flItPos) $ _floorItems w) where - crIsClose cr = dist (_crPos cr) camCen < winSize + pointIsClose p = dist camCen p < winSize winSize = 30 + max (getWindowX w) (getWindowY 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 w c = _spShape $ _crPict c c w diff --git a/src/Dodge/Render/ShapePicture.hs b/src/Dodge/Render/ShapePicture.hs index e7f33204b..e80476e3a 100644 --- a/src/Dodge/Render/ShapePicture.hs +++ b/src/Dodge/Render/ShapePicture.hs @@ -5,6 +5,7 @@ import Geometry import ShapePicture floorItemSPic :: FloorItem -> SPic -floorItemSPic flit = uncurryV translateSPf (_flItPos flit) - $ rotateSP (_flItRot flit) (_itFloorPict (_flIt flit)) +floorItemSPic flit + = uncurryV translateSPf (_flItPos flit) + $ rotateSP (_flItRot flit) (_itFloorPict (_flIt flit))