42 lines
1.1 KiB
Haskell
42 lines
1.1 KiB
Haskell
{- Specification of rooms that teleport (between levels). -}
|
|
module Dodge.Room.Teleport
|
|
where
|
|
import Dodge.Data
|
|
import Dodge.Base
|
|
import Dodge.LevelGen.Data
|
|
import Dodge.Room.Procedural
|
|
import Dodge.Placement.Instance
|
|
--import Dodge.LevelGen.Data
|
|
import Geometry
|
|
import Picture
|
|
import Dodge.WorldEvent.Explosion
|
|
|
|
import Control.Lens
|
|
import Control.Monad.State
|
|
import System.Random
|
|
|
|
telRoomLev
|
|
:: RandomGen g
|
|
=> Int -- ^ Level number to teleport to
|
|
-> State g Room
|
|
telRoomLev _ = do
|
|
w <- state $ randomR (200,300)
|
|
h <- state $ randomR (200,300)
|
|
return $ roomRectAutoLinks w h & rmPmnts .~
|
|
[ sPS (V2 (w/2) (h/2)) 0 $ PutPressPlate telPP
|
|
, sPS (V2 (w/2) (h/2+ 30)) 0 putLamp
|
|
]
|
|
where
|
|
telPP = PressPlate
|
|
{ _ppPict = setDepth 0.5 . color red $ polygon ppFootprint
|
|
, _ppPos = V2 0 0
|
|
, _ppRot = 0
|
|
, _ppEvent = levelReset
|
|
, _ppID = 0
|
|
, _ppText = "NEW LEVEL"
|
|
}
|
|
ppFootprint = rectNSEW 20 (-20) 20 (-20)
|
|
levelReset pp w
|
|
| dist (_crPos $ you w) (_ppPos pp) < 20 = makeExplosionAt (_ppPos pp) w
|
|
| otherwise = w
|