Commit before putting walls into vector zones

This commit is contained in:
2021-09-11 12:17:16 +01:00
parent 7c62ef4d48
commit 73beeacf3c
5 changed files with 51 additions and 0 deletions
+21
View File
@@ -4,6 +4,7 @@ module Dodge.Base.Zone
where
import Dodge.Data
import Dodge.Base.Window
import Dodge.Bounds
import Geometry
import Geometry.Zone
@@ -12,10 +13,30 @@ import Data.List
import Data.Bifunctor
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import qualified Data.Vector as V
zoneSize :: Float
zoneSize = 50
--zoneSize = 100
data Zoning a = Zoning
{ _znObjects :: V.Vector (V.Vector a)
, _znSize :: Int
, _znBounds :: Bounds
}
setupZoning :: Int -> Bounds -> a -> Zoning a
setupZoning size bounds x = Zoning
{ _znObjects = V.replicate xsize (V.replicate ysize x)
, _znSize = size
, _znBounds = bounds
}
where
toInt y = (ceiling y `div` size) + 1
xFloatSize = _bdMaxX bounds - _bdMinX bounds
yFloatSize = _bdMaxX bounds - _bdMinX bounds
xsize = toInt xFloatSize
ysize = toInt yFloatSize
floorHun :: Float -> Int
floorHun x = floor $ x / zoneSize