Add laser central room, using new placement/roompos functionality

This commit is contained in:
2021-11-21 17:44:32 +00:00
parent 48cd59069c
commit 2f3896345d
12 changed files with 127 additions and 76 deletions
+2 -1
View File
@@ -116,7 +116,8 @@ addButtonSlowDoor x h rm = do
aboveH y = (sndV2 . fst) y > h + 40
butDoor _ _ = putLitButOnPos col butPosCond
$ \btid -> Just $ putDoubleDoor False col (cond' btid) (V2 0 h) (V2 x h) 2
butPosCond (UnusedLink (V2 x' y') a') | y' < 0.5 * h = Just $ PS (V2 x' y') a'
butPosCond (UnusedLink (V2 x' y') a') | y' < 0.5 * h
= Just (PS (V2 x' y') a' , PosPl (V2 x' y') a')
butPosCond _ = Nothing
--butPosCond _ = True -- y < h
col = dim $ light red
+7 -6
View File
@@ -27,6 +27,7 @@ import System.Random
import Data.Maybe
import Data.Tree
import Data.Bifunctor
import Data.List
roomC :: RandomGen g => Float -> Float -> State g Room
roomC w h = do
@@ -104,7 +105,7 @@ glassSwitchBack = do
hgt <- state $ randomR (400,600)
wllen <- state $ randomR (60,wth/2-40)
let hf = hgt/5
con1 cond (UnusedLink (V2 x y) a) | cond y = Just $ PS (V2 x y) a
con1 cond (UnusedLink (V2 x y) a) | cond y = Just (PS (V2 x y) a , PosPl (V2 x y) a)
con1 _ _ = Nothing
plmnts =
[ mntLightLnkCond $ con1 (< 0.5 * hgt)
@@ -226,8 +227,8 @@ roomOctogon = defaultRoom
,( (0,40),pi)
]
roomNgon :: Int -> Room
roomNgon n = defaultRoom
roomNgon :: Int -> Float -> Room
roomNgon n x = defaultRoom
{ _rmPolys = [poly]
, _rmLinks = lnks
, _rmPath = [] -- TODO
@@ -241,9 +242,9 @@ roomNgon n = defaultRoom
poly = mapMaybe
(\(ra,rb) -> intersectLineLine' (rotateV ra bl) (rotateV ra br) (rotateV rb bl) (rotateV rb br))
$ loopPairs rots
bl = V2 100 100
br = V2 (-100) 100
lnks = map (\r -> (rotateV r (V2 0 100),r)) rots
bl = V2 x x
br = V2 (-x) x
lnks = sortOn ((\(V2 a b) -> (negate b,a)) . fst) $ map (\r -> (rotateV r (V2 0 x),r)) rots
allPairs :: Eq a => [a] -> [(a,a)]
allPairs xs = [(x,y) | x <- xs, y <- xs, x /= y]
+24 -6
View File
@@ -1,6 +1,7 @@
module Dodge.Room.Start
where
import Dodge.LevelGen.Data
import Dodge.PlacementSpot
import Dodge.Room.RunPast
import Dodge.Data
import Dodge.Default
@@ -19,11 +20,13 @@ import Dodge.Item.Random
import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.Utility
--import Dodge.LevelGen.Data
import Geometry.Data
--import Geometry.Data
import Geometry
import Padding
import Color
import Shape
import Data.Maybe
import Data.Tree
import Control.Monad.State
import Control.Lens
@@ -48,12 +51,27 @@ minigunfakeout = do
`treeFromPost` Right door
centralLasTurret :: Room
centralLasTurret = roomNgon 8
centralLasTurret = roomNgon 8 200 & rmPmnts .~
[ putLasTurret
, heightWall 30 (rectNSEW (-90) (-110) 10 (-10))
, spanColLightI 0.5 100 (V2 0 (-5)) (V2 0 5)
]
& rmExtPmnt ?~
--extTrigLitPos (PS (V2 200 0) 0)
--extTrigLitPos (anyLnkInPS 5)
extTrigLitPos fstLnkOut
( \tp -> Just $ lightSensor (upf $ fromJust $ _plMID tp) (V2 100 0) 0
)
where
upf trid mc w | _mcSensor mc > 90 = w & triggers . ix trid .~ const True
| otherwise = w
rezThenLasTurret :: RandomGen g => State g (Tree (Either Room Room))
rezThenLasTurret = do
rbox <- rezBoxStart
return $ rbox `appendEitherTree` [return $ Right centralLasTurret]
rbox <- rezBoxStart
let cenroom = centralLasTurret {_rmLabel = Just 0}
doorroom = switchDoorRoom {_rmTakeFrom = Just 0}
contTree = treeFromPost [Left cenroom] (Right doorroom)
return $ rbox `appendEitherTree` [contTree]
startRoom :: RandomGen g => State g (Tree (Either Room Room))
startRoom = join $ takeOne
@@ -193,7 +211,7 @@ startRoom' = do
, tankSquareEmboss4 (dim orange) 50 (h-60)
, tankSquare (dim orange) 50 50
, tankSquare (dim orange) 50 120
, lightSensor (V2 (0.8*w) (0.25*h)) 0
, lightSensor (const id) (V2 (0.8*w) (0.25*h)) 0
, putLasTurret & plSpot .~ PS (V2 (0.8*w) (0.8*h)) 0
, sps0 $ PutForeground $ colorSH orange $ pipePP 2 (V3 50 50 25) (V3 50 120 25)
]