Implement first weapon into tree structure
This commit is contained in:
@@ -6,19 +6,21 @@ import Geometry
|
||||
corridor :: Room
|
||||
corridor = Room
|
||||
{ _rmPolys = [rectNSWE 80 0 0 40
|
||||
,[(0,80), (0,80) +.+ rotateV (pi/3) (40,0),(40,80)]
|
||||
,[(40,0), (0,0) +.+ rotateV (0-pi/3) (40,0),( 0, 0)]
|
||||
-- ,[(0,80), (0,80) +.+ rotateV (pi/3) (40,0),(40,80)]
|
||||
-- ,[(40,0), (0,0) +.+ rotateV (0-pi/3) (40,0),( 0, 0)]
|
||||
]
|
||||
, _rmLinks = lnks
|
||||
, _rmPath = concatMap (doublePair . (,) (20,60)) $ map fst lnks
|
||||
, _rmPS = []
|
||||
, _rmBound = [] -- rectNSWE 50 30 0 40
|
||||
, _rmBound = rectNSWE 50 30 0 40
|
||||
}
|
||||
where
|
||||
lnks =
|
||||
[((20,70) ,0)
|
||||
,((20,80) +.+ rotateV (0-pi/3) (-10,0), pi/6)
|
||||
,((20,80) +.+ rotateV ( pi/3) ( 10,0),0-pi/6)
|
||||
-- ,((20,80) +.+ rotateV (0-pi/3) (-10,0), pi/6)
|
||||
-- ,((20,80) +.+ rotateV ( pi/3) ( 10,0),0-pi/6)
|
||||
,((20,70), pi/6)
|
||||
,((20,70), 0-pi/6)
|
||||
,((20,10) ,pi)
|
||||
]
|
||||
corridorN :: Room
|
||||
|
||||
@@ -18,3 +18,17 @@ data RoomLink = RL {_rlPos :: Point2, _rlRot :: Float}
|
||||
|
||||
makeLenses ''Room
|
||||
makeLenses ''RoomLink
|
||||
|
||||
-- want to split a room into its dimensions and contents
|
||||
|
||||
data Room' = Room'
|
||||
{ _dimensions :: Dimensions
|
||||
, _contents :: [PlacementSpot]
|
||||
}
|
||||
|
||||
data Dimensions = Dimensions
|
||||
{ _dmPolys :: [[Point2]]
|
||||
, _dmLinks :: [(Point2,Float)]
|
||||
, _dmPath :: [(Point2, Point2)]
|
||||
, _dmBound :: [Point2]
|
||||
}
|
||||
|
||||
+16
-2
@@ -1,3 +1,10 @@
|
||||
{-
|
||||
Concerns link pairs of rooms.
|
||||
Link pairs determine where rooms can attach to each other; each pair consists
|
||||
of a position and a rotation.
|
||||
The last link in the list is considered the incoming link, the other links are
|
||||
the outgoing links.
|
||||
-}
|
||||
module Dodge.Room.Link
|
||||
where
|
||||
import Dodge.LevelGen
|
||||
@@ -11,11 +18,18 @@ import Control.Monad.State
|
||||
import Control.Lens
|
||||
import Data.List (delete)
|
||||
|
||||
randLinks :: RandomGen g => Room -> State g Room
|
||||
randLinks r = do
|
||||
{- Shuffle the initial links of a room randomly. -}
|
||||
randomiseOutLinks :: RandomGen g => Room -> State g Room
|
||||
randomiseOutLinks r = do
|
||||
newLinks <- shuffle $ init $ _rmLinks r
|
||||
return $ r {_rmLinks = newLinks ++ [last $ _rmLinks r]}
|
||||
|
||||
{- Shuffle all links of a room randomly. -}
|
||||
randomiseAllLinks :: RandomGen g => Room -> State g Room
|
||||
randomiseAllLinks r = do
|
||||
newLinks <- shuffle $ _rmLinks r
|
||||
return $ r {_rmLinks = newLinks}
|
||||
|
||||
filterLinks :: RandomGen g => ((Point2,Float) -> Bool) -> Room -> State g Room
|
||||
filterLinks cond r = do
|
||||
newLinks <- shuffle $ filter cond $ init $ _rmLinks r
|
||||
|
||||
@@ -8,6 +8,8 @@ import Geometry
|
||||
|
||||
import Data.List (nub,sortBy)
|
||||
import Data.Function (on)
|
||||
--import Control.Monad.State
|
||||
--import System.Random
|
||||
{-
|
||||
A simple rectangular room with a light in the center.
|
||||
Creates links and pathfinding graph.
|
||||
@@ -58,3 +60,4 @@ makeRect x y = [((0,0),(x,0))
|
||||
linksAndPath :: [(Point2,Float)] -> [(Point2,Point2)] -> [(Point2,Point2)]
|
||||
linksAndPath lnks subpth = subpth ++ concatMap linkClosest lnks
|
||||
where linkClosest (p,_) = doublePair (p, head $ sortBy (compare `on` dist p) $ map fst subpth)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user