Commit before putting walls into vector zones
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import Dodge.Config.KeyConfig
|
||||
import Dodge.Item.Attachment.Data
|
||||
import Dodge.Item.Data
|
||||
import Dodge.World.Trigger.Data
|
||||
import Dodge.Bounds
|
||||
import Data.Preload
|
||||
import Picture.Data
|
||||
import Geometry.Data
|
||||
@@ -109,6 +110,7 @@ data World = World
|
||||
, _gameRooms :: [GameRoom]
|
||||
, _preloadData :: PreloadData
|
||||
, _frameClock :: Int
|
||||
, _worldBounds :: Bounds
|
||||
}
|
||||
data OptionScreenFlag = NormalOptions | GameOverOptions
|
||||
data ScreenLayer
|
||||
|
||||
@@ -6,6 +6,7 @@ import Dodge.Debug.Flag.Data
|
||||
import Dodge.Config.Data
|
||||
import Dodge.Config.KeyConfig
|
||||
import Dodge.Item.Data
|
||||
import Dodge.Bounds
|
||||
--import Dodge.Menu
|
||||
--import Picture
|
||||
import Geometry.Data
|
||||
@@ -85,6 +86,7 @@ defaultWorld = World
|
||||
, _gameRooms = []
|
||||
, _preloadData = DummyPdata -- hack TODO remove this
|
||||
, _frameClock = 0
|
||||
, _worldBounds = defaultBounds
|
||||
}
|
||||
defaultDebugFlags :: DebugFlags
|
||||
defaultDebugFlags = DebugFlags
|
||||
|
||||
@@ -67,6 +67,12 @@ wallsAndWindows w
|
||||
(wins,wls) = partition _wlIsSeeThrough . IM.elems $ wallsDoubleScreen w
|
||||
testStringInit :: World -> [String]
|
||||
testStringInit _ = []
|
||||
--testStringInit w =
|
||||
-- [show $ _worldMinX w
|
||||
-- ,show $ _worldMaxX w
|
||||
-- ,show $ _worldMinY w
|
||||
-- ,show $ _worldMaxY w
|
||||
-- ]
|
||||
--testStringInit = mapMaybe f . IM.elems . wallsDoubleScreen
|
||||
-- where
|
||||
-- f (dr@Door{}) = Just . show $ _wlLine dr
|
||||
|
||||
@@ -7,6 +7,7 @@ import Dodge.LevelGen.StaticWalls
|
||||
import Dodge.Base
|
||||
import Dodge.Base.Zone
|
||||
import Dodge.GameRoom
|
||||
import Dodge.Bounds
|
||||
--import Dodge.RandomHelp
|
||||
import Dodge.Graph
|
||||
import Dodge.Layout.Tree.Polymorphic (applyToRoot)
|
||||
@@ -32,9 +33,12 @@ import Data.Tree
|
||||
import Data.Graph.Inductive.Graph (labNodes)
|
||||
import qualified Data.Map as M
|
||||
import Data.Foldable
|
||||
import qualified Control.Foldl as L
|
||||
import Data.Maybe
|
||||
|
||||
generateLevelFromRoomList :: State StdGen [Room] -> World -> World
|
||||
generateLevelFromRoomList gr w = updateWallZoning
|
||||
. setupWorldBounds
|
||||
-- . initializeStaticWalls
|
||||
. setupForegroundEdgeVerxs
|
||||
. placeSpots plmnts
|
||||
@@ -54,6 +58,22 @@ generateLevelFromRoomList gr w = updateWallZoning
|
||||
zs = map fromIntegral $ randomRs (0,63::Int) $ _randGen w
|
||||
rs' = evalState gr $ _randGen w
|
||||
|
||||
setupWorldBounds :: World -> World
|
||||
setupWorldBounds w = w
|
||||
& worldBounds . bdMinX .~ f minx
|
||||
& worldBounds . bdMaxX .~ f maxx
|
||||
& worldBounds . bdMinY .~ f miny
|
||||
& worldBounds . bdMaxY .~ f maxy
|
||||
where
|
||||
f = fromMaybe 0
|
||||
ps = IM.map (fst . _wlLine) $ _walls w
|
||||
(minx,maxx,miny,maxy) = L.fold ((,,,)
|
||||
<$> L.premap fstV2 L.minimum
|
||||
<*> L.premap fstV2 L.maximum
|
||||
<*> L.premap sndV2 L.minimum
|
||||
<*> L.premap sndV2 L.maximum
|
||||
) ps
|
||||
|
||||
setupForegroundEdgeVerxs :: World -> World
|
||||
setupForegroundEdgeVerxs w = w & foregroundEdgeVerx .~ polyhedrasToEdges (_foregroundDecorations w)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user