Files
loop/src/Dodge/LevelGen/Switch.hs
T

59 lines
1.5 KiB
Haskell

module Dodge.LevelGen.Switch
( makeSwitch
, makeButton
, makeSwitchSPic
, drawSwitchWire
) where
import Dodge.Data.Button
import Dodge.Data.WorldEffect
import Dodge.Default
import Dodge.SoundLogic
import Picture
import ShapePicture
import Shape
import Geometry
makeButton
:: Color
-> WdWd -- ^ Effect when pressed
-> Button
makeButton col eff = defaultButton
{ _btPict = DefaultDrawButton col
, _btEvent = ButtonPress BtNoLabel ButtonDoNothing click1S eff
, _btText = "Button"
, _btState = BtOff
}
drawSwitchWire :: Color -> Color -> Button -> SPic
drawSwitchWire col1 col2 bt
| _btState bt == BtOff = flick $ pi/4
| otherwise = flick (negate (pi/4))
where
flick a = ( mconcat
[ colorSH col1 . translateSHz 10 . upperPrismPoly 10 $ reverse $ rectNSWE (-2) (-5) (-10) 10
, colorSH col2 . translateSH (V3 0 (-2) 15) . rotateSH a . upperPrismPoly 2 . reverse
$ rectNSWE 10 0 (-2) 2
]
, mempty)
makeSwitchSPic
:: ButtonDraw
-> WdWd -- ^ Switch on effect
-> WdWd -- ^ Switch off effect
-> Button
makeSwitchSPic dswitch effOn effOff = defaultButton
{ _btPict = dswitch
, _btEvent = ButtonSimpleSwith effOn effOff
, _btText = "SWITCH/"
, _btState = BtOff
}
makeSwitch
:: Color
-> Color
-> WdWd -- ^ Switch on effect
-> WdWd -- ^ Switch off effect
-> Button
makeSwitch col1 col2 = makeSwitchSPic (DefaultDrawSwitch col1 col2)