Implement simple sweep light
This commit is contained in:
@@ -489,6 +489,13 @@ data Prop
|
|||||||
, _pjUpdate :: Prop -> World -> World
|
, _pjUpdate :: Prop -> World -> World
|
||||||
, _pjTime :: Int
|
, _pjTime :: Int
|
||||||
}
|
}
|
||||||
|
| ShapeProp
|
||||||
|
{ _pjPos :: Point2
|
||||||
|
, _pjID :: Int
|
||||||
|
, _pjRot :: Float
|
||||||
|
, _pjUpdate :: Prop -> World -> World
|
||||||
|
, _prDraw :: Prop -> SPic
|
||||||
|
}
|
||||||
| Shell
|
| Shell
|
||||||
{ _pjPos :: Point2
|
{ _pjPos :: Point2
|
||||||
, _pjStartPos :: Point2
|
, _pjStartPos :: Point2
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ placeSpots pss w = foldr (placeSpot . _placementSpot) w' singlePlacements
|
|||||||
{- | -}
|
{- | -}
|
||||||
placeSpot :: PlacementSpot -> World -> World
|
placeSpot :: PlacementSpot -> World -> World
|
||||||
placeSpot ps w = case _psType ps of
|
placeSpot ps w = case _psType ps of
|
||||||
|
PutProp prop -> placeProp prop p rot w
|
||||||
PutButton bt -> placeBt bt p rot w
|
PutButton bt -> placeBt bt p rot w
|
||||||
PutFlIt itm -> placeFlIt itm p rot w
|
PutFlIt itm -> placeFlIt itm p rot w
|
||||||
PutCrit cr -> placeCr cr p rot w
|
PutCrit cr -> placeCr cr p rot w
|
||||||
@@ -146,6 +147,17 @@ addPane wl (p0,p1) wls = IM.insert (IM.newKey wls) (wl
|
|||||||
})
|
})
|
||||||
wls
|
wls
|
||||||
|
|
||||||
|
-- TODO make rotation of props sensible
|
||||||
|
placeProp
|
||||||
|
:: Prop
|
||||||
|
-> Point2
|
||||||
|
-> Float -- ^ Rotation
|
||||||
|
-> World
|
||||||
|
-> World
|
||||||
|
placeProp pr p a = over props addProp
|
||||||
|
where
|
||||||
|
addProp prs = IM.insert (IM.newKey prs) (over pjRot (+a) pr {_pjPos = p, _pjID = IM.newKey prs}) prs
|
||||||
|
|
||||||
placeBt
|
placeBt
|
||||||
:: Button
|
:: Button
|
||||||
-> Point2
|
-> Point2
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import System.Random
|
|||||||
data PSType = PutCrit {_unPutCrit :: Creature}
|
data PSType = PutCrit {_unPutCrit :: Creature}
|
||||||
| PutLS LightSource Picture
|
| PutLS LightSource Picture
|
||||||
| PutButton Button
|
| PutButton Button
|
||||||
|
| PutProp Prop
|
||||||
| PutFlIt Item
|
| PutFlIt Item
|
||||||
| PutPressPlate PressPlate
|
| PutPressPlate PressPlate
|
||||||
| PutAutoDoor Point2 Point2
|
| PutAutoDoor Point2 Point2
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ module Dodge.LightSources
|
|||||||
, lightAt
|
, lightAt
|
||||||
, colorLightAt
|
, colorLightAt
|
||||||
, lampPic
|
, lampPic
|
||||||
|
, lampCover
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Picture
|
import Picture
|
||||||
|
import ShapePicture
|
||||||
|
import Shape
|
||||||
|
import Geometry
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
@@ -62,3 +66,31 @@ tLight t rmax col (V3 x y z) = TLS
|
|||||||
lampPic :: Float -> Picture
|
lampPic :: Float -> Picture
|
||||||
--{-# INLINE lampPic #-}
|
--{-# INLINE lampPic #-}
|
||||||
lampPic h = setLayer 1 (setDepth h . color white $ circleSolid 3)
|
lampPic h = setLayer 1 (setDepth h . color white $ circleSolid 3)
|
||||||
|
|
||||||
|
lampCover :: Float -> Prop
|
||||||
|
lampCover h = ShapeProp
|
||||||
|
{ _pjPos = V2 0 0
|
||||||
|
, _pjID = 0
|
||||||
|
, _pjRot = 0
|
||||||
|
, _pjUpdate = updateLampCover
|
||||||
|
, _prDraw = drawLampCover h
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLampCover :: Prop -> World -> World
|
||||||
|
updateLampCover pr w = w
|
||||||
|
& props . ix (_pjID pr) . pjRot +~ 0.15
|
||||||
|
|
||||||
|
drawLampCover :: Float -> Prop -> SPic
|
||||||
|
drawLampCover h pr =
|
||||||
|
( translateSHz (h-2.5) . uncurryV translateSHf pos
|
||||||
|
$ rotateSH a $ mconcat
|
||||||
|
[ upperPrismPoly 5 $ rectNSEW 6 5 6 (-4)
|
||||||
|
, upperPrismPoly 5 $ rectNSEW 6 (-4) 6 5
|
||||||
|
--, translateSHz 2.5 . upperPrismPoly 1 $ [V2 5 5,V2 (-4) 5,V2 5 (-4)]
|
||||||
|
, upperPrismPoly 1 $ [V2 5 5,V2 (-4) 5,V2 5 (-4)]
|
||||||
|
]
|
||||||
|
, mempty
|
||||||
|
)
|
||||||
|
where
|
||||||
|
a = _pjRot pr
|
||||||
|
pos = _pjPos pr
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ corridor = defaultRoom
|
|||||||
, _rmLinks = lnks
|
, _rmLinks = lnks
|
||||||
, _rmPath = concatMap (doublePair . (,) (V2 20 60) . fst) lnks
|
, _rmPath = concatMap (doublePair . (,) (V2 20 60) . fst) lnks
|
||||||
, _rmPS =
|
, _rmPS =
|
||||||
[ sPS (V2 20 40) 0 $ PutLS (lightAt (V3 0 0 50) 0) (lampPic 50)
|
[-- sPS (V2 20 40) 0 $ PutLS (lightAt (V3 0 0 50) 0) (lampPic 50)
|
||||||
, sPS (V2 0 0) 0 $ PutForeground $ highPipe 55 (V2 0 40) (V2 40 40)
|
sPS (V2 0 0) 0 $ PutForeground $ highPipe 55 (V2 0 40) (V2 40 40)
|
||||||
]
|
]
|
||||||
, _rmBound = [ rectNSWE 50 30 0 40 ]
|
, _rmBound = [ rectNSWE 50 30 0 40 ]
|
||||||
, _rmFloor = [makeTileFromPoly poly 2]
|
, _rmFloor = [makeTileFromPoly poly 2]
|
||||||
|
|||||||
+12
-3
@@ -8,6 +8,7 @@ import Dodge.Room.Placement
|
|||||||
import Dodge.Room.Foreground
|
import Dodge.Room.Foreground
|
||||||
import Dodge.Layout.Tree.Polymorphic
|
import Dodge.Layout.Tree.Polymorphic
|
||||||
import Dodge.LevelGen.Data
|
import Dodge.LevelGen.Data
|
||||||
|
import Dodge.LightSources
|
||||||
--import Picture
|
--import Picture
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
|
|
||||||
@@ -24,13 +25,21 @@ startRoom = do
|
|||||||
w <- state $ randomR (100,400)
|
w <- state $ randomR (100,400)
|
||||||
h <- state $ randomR (200,400)
|
h <- state $ randomR (200,400)
|
||||||
let fground = sPS (V2 0 0) 0 $ PutForeground $
|
let fground = sPS (V2 0 0) 0 $ PutForeground $
|
||||||
girderV 50 20 10 (V2 0 (h/5)) (V2 w (h/5))
|
girderV 40 20 10 (V2 0 (h/6)) (V2 w (h/6))
|
||||||
<> highPipe 40 (V2 0 (h/2)) (V2 w (h/3))
|
<> highPipe 40 (V2 0 (h/2)) (V2 w (h/2))
|
||||||
<> highPipe 60 (V2 (w/3) 0 ) (V2 (w/3) h )
|
<> highPipe 60 (V2 (w/3) 0 ) (V2 (w/3) h )
|
||||||
theLamp = sPS (V2 (w/2) (h/2)) 0 $ putColorLamp (V3 0.75 0.75 0.75)
|
theLamp = sPS (V2 (w/2) (h/2)) 0 $ putColorLamp (V3 0.75 0.75 0.75)
|
||||||
treeFromPost [Left rezBox, Left door] . Right
|
treeFromPost [Left rezBox, Left door] . Right
|
||||||
<$> randomiseOutLinks (shiftRoomBy (V2 (-20) (-20),0)
|
<$> randomiseOutLinks (shiftRoomBy (V2 (-20) (-20),0)
|
||||||
$ roomRectAutoLinks w h & rmPS .~ [fground,theLamp])
|
$ roomRectAutoLinks w h & rmPS .~
|
||||||
|
[ fground
|
||||||
|
--, theLamp
|
||||||
|
, sPS (V2 100 100) 0 $ PutLS (colorLightAt (V3 0.75 0 0) (V3 0 0 lampHeight) 0) (lampPic lampHeight)
|
||||||
|
, sPS (V2 100 100) 0 $ PutProp $ lampCover lampHeight
|
||||||
|
]
|
||||||
|
)
|
||||||
|
where
|
||||||
|
lampHeight = 41
|
||||||
-- where
|
-- where
|
||||||
-- cola = dark . dark . light . light $ light red
|
-- cola = dark . dark . light . light $ light red
|
||||||
-- colb = dark . dark . light . light $ light blue
|
-- colb = dark . dark . light . light $ light blue
|
||||||
|
|||||||
Reference in New Issue
Block a user