module Dodge.LevelGen.Switch ( makeSwitch, makeButton, drawSwitchWire, ) where import Dodge.Data.Button import Dodge.Data.WorldEffect import Dodge.Default import Geometry import Picture import Shape import ShapePicture import Control.Lens makeButton :: Color -> -- | Effect when pressed WdWd -> Button makeButton col eff = defaultButton { _btEvent = ButtonPress False eff col } -- TODO remove duplication drawSwitchWire :: Color -> Color -> Button -> SPic drawSwitchWire col1 col2 bt | bt ^? btEvent . btOn == Just False = flick $ pi / 4 | otherwise = flick (negate (pi / 4)) where flick a = noPic ( mconcat [ colorSH col1 . translateSHz 10 . upperBox Small Typical 10 $ rectNSWE (-2) (-5) (-10) 10 , colorSH col2 . translateSH (V3 0 (-2) 15) . rotateSH a . upperBox Small Typical 2 $ rectNSWE 10 0 (-2) 2 ] ) makeSwitch :: Color -> Color -> WdWd -> WdWd -> Button makeSwitch c1 c2 fon foff = defaultButton & btEvent .~ ButtonSwitch fon foff c1 c2 False