Draw floor item shapes

This commit is contained in:
2021-09-22 11:54:25 +01:00
parent fa7d8e1b50
commit 27a780ff47
3 changed files with 22 additions and 6 deletions
+3 -6
View File
@@ -10,6 +10,7 @@ import Dodge.Picture.SizeInvariant
import Dodge.Picture.Layer
import Dodge.Render.HUD
import Dodge.Render.MenuScreen
import Dodge.Render.ShapePicture
import Dodge.SoundLogic.LoadSound
import Dodge.Config.Data
import Sound.Data
@@ -30,7 +31,7 @@ worldPictures w = pictures
,concatMapPic (crDraw w) . IM.filter crIsClose $ _creatures w
,concatMapPic (dbArg _ptDraw) $ _particles w
,testPic w
,concatMapPic drawItem $ _floorItems w
,concatMapPic (_spPicture . floorItemSPic) $ _floorItems w
,concatMapPic (crDraw w) $ _creatures w
,concatMapPic clDraw $ _clouds w
,concatMapPic ppDraw $ _pressPlates w
@@ -42,7 +43,7 @@ worldPictures w = pictures
crIsClose cr = dist (_crPos cr) camCen < winSize
winSize = 30 + max (getWindowX w) (getWindowY w)
camCen = _cameraCenter w
fixedCoordPictures :: World -> Picture
fixedCoordPictures w = case _menuLayers w of
[] -> pictures
@@ -194,10 +195,6 @@ extendConeToScreenEdge w c (x,y) = orderPolygon $ wallScreenIntersect ++ [x,y] +
rectangleSolid :: Float -> Float -> Picture
rectangleSolid x y = polygon $ map toV2 [(x,y),(x,-y),(-x,-y),(-x,y)]
drawItem :: FloorItem -> Picture
drawItem flit = uncurryV translate (_flItPos flit)
$ rotate (_flItRot flit) (_spPicture $ _itFloorPict (_flIt flit))
ffToDraw :: World -> [ForceField]
ffToDraw _ = []
+9
View File
@@ -6,15 +6,24 @@ import Geometry
--import Color
import ShapePicture
import Dodge.Base.Window
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)
where
crIsClose cr = dist (_crPos cr) camCen < 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
+10
View File
@@ -0,0 +1,10 @@
module Dodge.Render.ShapePicture
where
import Dodge.Data
import Geometry
import ShapePicture
floorItemSPic :: FloorItem -> SPic
floorItemSPic flit = uncurryV translateSPf (_flItPos flit)
$ rotateSP (_flItRot flit) (_itFloorPict (_flIt flit))