Working use of links as placement spots
This commit is contained in:
@@ -239,8 +239,8 @@ defaultDrawButton col bt =
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
buttonGeometry
|
buttonGeometry
|
||||||
| _btState bt == BtOff = rectWH width 5
|
| _btState bt == BtOff = rectNSEW 10 (-1) width (-width)
|
||||||
| otherwise = rectNSEW (-3) (-5) width (-width)
|
| otherwise = rectNSEW 2 (-1) width (-width)
|
||||||
width = 8
|
width = 8
|
||||||
defaultButton :: Button
|
defaultButton :: Button
|
||||||
defaultButton = Button
|
defaultButton = Button
|
||||||
|
|||||||
+6
-6
@@ -7,6 +7,7 @@ import Dodge.LevelGen.Data
|
|||||||
import Dodge.LevelGen.StaticWalls
|
import Dodge.LevelGen.StaticWalls
|
||||||
import Dodge.LevelGen.Pathing
|
import Dodge.LevelGen.Pathing
|
||||||
import Dodge.Placements.Spot
|
import Dodge.Placements.Spot
|
||||||
|
import Dodge.RandomHelp
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
import Dodge.GameRoom
|
import Dodge.GameRoom
|
||||||
@@ -52,21 +53,20 @@ generateLevelFromRoomList gr w
|
|||||||
where
|
where
|
||||||
path = pairsToGraph dist pairPath
|
path = pairsToGraph dist pairPath
|
||||||
pairPath = concatMap _rmPath rs
|
pairPath = concatMap _rmPath rs
|
||||||
plmnts = concatMap (\r -> map (_rmShift r ,) (assignPlacementSpots r)) rs
|
plmnts = concat . snd $ mapAccumR assignPlacementSpots (_randGen w) rs
|
||||||
rs = zipWith addTile zs . evalState gr $ _randGen w
|
rs = zipWith addTile zs . evalState gr $ _randGen w
|
||||||
zs = map fromIntegral $ randomRs (0,63::Int) $ _randGen w
|
zs = map fromIntegral $ randomRs (0,63::Int) $ _randGen w
|
||||||
|
|
||||||
-- the idea is to allow use of link coordinates for placements
|
-- the idea is to allow use of link coordinates for placements
|
||||||
-- though the implementation is clunky
|
-- though the implementation is clunky
|
||||||
assignPlacementSpots :: Room -> [Placement]
|
assignPlacementSpots :: StdGen -> Room -> (StdGen, [((Point2,Float),Placement)])
|
||||||
assignPlacementSpots rm = plmnts ++ plmnts'
|
assignPlacementSpots g rm = (g', map (_rmShift rm,) $ plmnts ++ plmnts')
|
||||||
where
|
where
|
||||||
(lnkplmnts, plmnts) = partition islnk (_rmPS rm)
|
(lnkplmnts, plmnts) = partition islnk (_rmPS rm)
|
||||||
islnk Placement{_placementSpot=PSLnk{}} = True
|
islnk Placement{_placementSpot=PSLnk{}} = True
|
||||||
islnk _ = False
|
islnk _ = False
|
||||||
(_,plmnts') = mapAccumR f (map (invShiftLinkBy lnkTo) $ _rmLinks rm) lnkplmnts
|
(shuffledLnks,g') = runState (shuffle $ _rmLinks rm) g
|
||||||
(la,lb) = _rmShift rm
|
(_,plmnts') = mapAccumR f (map (invShiftLinkBy $ _rmShift rm) shuffledLnks) lnkplmnts
|
||||||
lnkTo = (la,lb)
|
|
||||||
f lnks plmnt =
|
f lnks plmnt =
|
||||||
let (x:xs,ys) = partition (_psLinkTest $ _placementSpot plmnt) lnks
|
let (x:xs,ys) = partition (_psLinkTest $ _placementSpot plmnt) lnks
|
||||||
thepair = _psLinkShift (_placementSpot plmnt) x
|
thepair = _psLinkShift (_placementSpot plmnt) x
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ putLitButtonID col p a subpl = mountLightAID ls p'' (addZ 40 p')
|
|||||||
ls = defaultLS { _lsRad = 75 , _lsIntensity = V3 0.5 0 0 }
|
ls = defaultLS { _lsRad = 75 , _lsIntensity = V3 0.5 0 0 }
|
||||||
|
|
||||||
putLitButtonID' :: Color -> ((Point2,Float) -> Bool) -> (Int -> Maybe Placement) -> Placement
|
putLitButtonID' :: Color -> ((Point2,Float) -> Bool) -> (Int -> Maybe Placement) -> Placement
|
||||||
putLitButtonID' col f subpl = updatePSToLevel 3 (const thePS) $ mountLightAID ls 0 (V3 0 40 40)
|
putLitButtonID' col f subpl = updatePSToLevel 3 (const thePS) $ mountLightAID ls 0 (V3 0 (-40) 40)
|
||||||
$ \lsid -> jps0 (PutButton (makeButton col (changeLight lsid)) {_btPos = 0, _btRot = 0})
|
$ \lsid -> jps0 (PutButton (makeButton col (changeLight lsid)) {_btPos = V2 0 (-1), _btRot = pi})
|
||||||
subpl
|
subpl
|
||||||
where
|
where
|
||||||
changeLight lsid = lightSources . ix lsid . lsIntensity .~ V3 0 0.5 0
|
changeLight lsid = lightSources . ix lsid . lsIntensity .~ V3 0 0.5 0
|
||||||
|
|||||||
Reference in New Issue
Block a user